Next.js Discord

Discord Forum

Deploying Next API to a subdomain

Unanswered
jgoon posted this in #help-forum
Open in Discord
Instead of deploying to domain.com/api is it possible to deploy it to api.domain.com?

10 Replies

@jgoon Instead of deploying to `domain.com/api` is it possible to deploy it to `api.domain.com`?
Broad-snouted Caiman
Domain doesnt matter i guess
Beacuse its always /api/test.js
No matter domain
@Broad-snouted Caiman No matter domain
so you simply can't change the domain
@jgoon so you simply can't change the domain
Broad-snouted Caiman
Nextjs always gave /api in it
You can use express js if u want api.something.com
yeah im currently switching from express to next bc serverless makes more sense, currently deployed on api.domain.com and wanted to see if i count keep that not a big issue tho
@Broad-snouted Caiman Nextjs always gave /api in it
this is incorrect for app dir
@jgoon Instead of deploying to `domain.com/api` is it possible to deploy it to `api.domain.com`?
if you use the app router, you dont need the /api part

if you use the pages router, you need the /api part, but you can always deploy it to, say, jgoon.domain.com/api and then make another app at api.domain.com that rewrites to this jgoon.domain.com/api.