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
Perfect16mo 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
Neto16mo ago
using next? or what tech?
Perfect
Perfect16mo 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
Neto16mo 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
Perfect16mo 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
Neto16mo ago
For a simple approach, just use the subdomain
Perfect
Perfect16mo ago
Ok 👌 sounds good Thx