#Is there a new way of working with the api endpoints?

7 messages · Page 1 of 1 (latest)

dull axle
#

I am used to the way of having a src folder, with an api folder inside and inside the api folder, naming files endpoint1.ts to be ables to access /api/endpoint1

Although now I am not able to do that. I also cannot find documentation stating that isnt the case anymore. For context, my new codebase does not have a src folder anymore.

chilly oakBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

tame maple
#

The way you go about doing it is similar to the way you setup a page to be a valid route.

#

With a page, you name the folder what you want the page to be on the url path, then put a page.tsx in it to register it.

#

You do the same for api endpoints, however unlike in Next12, you can put it in any folder, just name the file route.ts

#

Disclaimer: a path cannot have both route.ts and page.tsx, one will overwrite the other (I believe page takes priority)