identical urls page vs api

Noob question - If my site has a page at /posts, but my api also has a /posts route. Is it possible to differentiate? Should I prefix all my api routes like /api/posts for example?
7 Replies
Perfect
Perfect2y ago
I guess this wouldn’t happen if my api is on a different server, I could add a subdomain api.domain.com/posts
Neto
Neto2y ago
using next? or what tech?
Perfect
Perfect2y ago
@Neto going to be using nextjs for frontend and express for my backend. Turbo repo and prisma (guess that’s not really relevant)
Neto
Neto2y ago
If you where using next for both /some would be a page /api/some would be a API route But as they are different applications, a subdomain is enough
Perfect
Perfect2y ago
Ok cool Is there any other alternative? Or is subdomain the go to if express is living on its own on a server
Neto
Neto2y ago
For a simple approach, just use the subdomain
Perfect
Perfect2y ago
Ok 👌 sounds good Thx
Want results from more Discord servers?
Add your server