ldmichae
(Logan Michaels)
May 28, 2025, 3:41pm
1
I am working with the Vercel Rust community runtime (repo here) , and I am experiencing issues with local development identical to others in previous unresolved support threads:
Hi - I’m attempting to deploy a Next.js app on Vercel with both Vercel Go serverless functions - and API routes.
This is my folder structure:
[image]
Under /api I have a list.go function with a Handler function. Per the documentation, this should be queryable at /api/list - and it is.
Under /src/app/api - I have ./auth/[...nextauth]/route.ts which is my next-auth handler code. I expect this to be queryable at /api/auth/*.
When I deploy this on Vercel - or when I run it locally with vercel…
API routes generated from Next.js generate a permanent, default 404 page when coupled with an additional, custom Go function.
The Go function is working correctly, but the API routes generated by Next.js are returning a permanent 404 page. The Go function is placed in the top-level /api/<go-function>.go , while the API route is located in src/app/api/<route-name>/route.ts.
file structure
api
server-lookup.go
src
app/api/check-upvote
[slug]
route.ts
expected behavior
Both Next.…
I’m curious if anyone has further guidance on this, as things work perfectly fine when deployed, but it is impossible to develop locally using vercel dev
, as the community runtime endpoints work but Next api routes return 404.
1 Like
system
(system)
May 28, 2025, 3:41pm
2
There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.
Sometimes things don’t go as expected when deploying a website. If you see a 404 on your site, that means the page or resource couldn’t be found.
There are many possible causes, and the absence of something can be tricky debug if you don’t know where to look. Here are some things you can do to find the cause and fix it.
Debugging Tips
Check the error code
If you see a mostly white screen with 404: NOT_FOUND along with a Code and and ID then you can click the blue info box below the error deta…
A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0 .
Hey, yes, I got it working.
You need to place your Next.js API routes inside of something different from api
, like api-n
.
Then, update vercel.json
accordingly. In my case, the Go function is placed on the /api/server-lookup
, so vercel.json
looks like this:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"rewrites": [
{
"source": "/api/server-lookup",
"destination": "/api/server-lookup"
},
{
"source": "/api/:path*",
"destination": "/api-n/:path*"
}
]
}
I’ve also made the whole application easier to work with by updating the next.config.ts
(when temporarily using next dev
instead of vercel dev
):
import type { NextConfig } from "next";
import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
const nextConfig = async (
phase: string,
{ defaultConfig }: { defaultConfig: NextConfig }
): Promise<NextConfig> => {
const config: NextConfig =
phase === PHASE_DEVELOPMENT_SERVER
? {
rewrites: async () => {
return [
{
source: "/api/:path*",
destination: "/api-n/:path*",
},
];
},
}
: {};
return {
...defaultConfig,
...config,
};
};
export default nextConfig;
Hope it helps!