framework icon indicating copy to clipboard operation
framework copied to clipboard

Server Routes documentation : ~/server/api vs ~/server/routes

Open provok-me opened this issue 2 years ago • 4 comments

Describe the feature

The v3 documentation doesn't really explain the real difference between routes and api directories inside the server dir.

Apart from "If you don't want to use ~/server/api, you can use ~/server/routes instead", we can't really understand their meaning.

• Why were they created in the first place? • When should I use routes instead of api?

The Nitro doc doesn't answer these questions either.

PS It may be great to add a "✍️ Doc upgrade" option to this list.

Capture d’écran 2022-08-30 à 09 08 31

Additional information

  • [ ] Would you be willing to help implement this feature?
  • [ ] Could this feature be implemented as a module?

Final checks

provok-me avatar Aug 30 '22 07:08 provok-me

Hi, i find it clear in the doc, there is even an example, it's just a path name choice. I could want to name my api endpoint https://ww.foo.com/barApi instead of https://www.foo.com/api/bar. If you don't want the /api/ part, you place it in a server/route folder.

Joaojack avatar Aug 30 '22 07:08 Joaojack

PR welcome to improve the docs.

pi0 avatar Aug 30 '22 08:08 pi0

Thanks @Joaojack, I thought there was something more profound I didn't get 😂

provok-me avatar Aug 30 '22 11:08 provok-me

Docs for reference:

https://v3.nuxtjs.org/guide/directory-structure/server#server-directory

sevillaarvin avatar Sep 22 '22 15:09 sevillaarvin