Next.js Discord

Discord Forum

Vercel Serverless functions behaving differently in 'vercel dev', than in 'vercel'?

Unanswered
Havana posted this in #help-forum
Open in Discord
HavanaOP
Having issues with local development using Vercel CLI.

My current setup for my 2 API endpoints:
/api/foo/index.go
/src/app/api/bar/route.ts

When I run the project locally with vercel dev, I'm only able to access http://localhost:3000/api/foo. If I attempt to access http://localhost:3000/api/bar, I get a 404 (see attached img).

However, if I do a preview deployment, vercel, I'm able to access both API endpoints. No change in configuration between the two deployments.

Ideally, I'd like to be able to run my serverless GoLang functions locally on the same port as the rest of my app, but a workaround might need to be vercel dev and then next dev on different port.

Maybe I'm missing some documentation somewhere? I've tried using functions in the vercel.json config, but no luck. And not sure if I could solve this with middleware somehow?

Thanks.

2 Replies

HavanaOP
I see that the api route in the app router is classed as an ISR function, and the root-level api is classed as a vercel function. How am I able to get these to work together at the same time in vercel dev?
this server is nextjs-centric so very few people can help you here. i suggest you go to vercel discussions https://github.com/vercel/discussions