While running packages/api in dev, it works and i used vercel link and ran the packages/api on localhost:4000 using vercel.json to give it vercel environment. But when i hosted it on vercel it shows 404 and i cant access any route. i think something is wrong with vercel.json but its still running perfectly in vercel cli.
It should run like vercel cli but the route still says 404
{
“version”: 2,
“builds”: [
{
“src”: “dist/index.js”,
“use”: “@vercel /node”,
“config”: { “includeFiles”: [“../../packages/**”] }
}
],
“routes”: [
{
“src”: “/api/trpc(?:/.)?",
“dest”: “dist/index.js”,
“headers”: {
“Access-Control-Allow-Origin”: " ”,
“Access-Control-Allow-Methods”: “GET, POST, OPTIONS”,
“Access-Control-Allow-Headers”: “Content-Type, Authorization”,
“Access-Control-Allow-Credentials”: “true”
}
}
],
“env”: {
“NODE_ENV”: “production”
}
}
this is the current vercel.json, am i missing something
system
(system)
October 24, 2025, 10:13am
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 .
pawlean
(Pauline P. Narvas)
October 24, 2025, 10:35am
5
Hey, Rohit! Welcome to the Vercel Community. Nice to see you here
Looking at your setup, there are a few potential issues with your vercel.json configuration that could cause the 404 errors in production.
Could you make sure your dist/index.js file actually exists after the build? Vercel might not be finding your built files in the expected location.
Your route pattern /api/trpc(?:/.*)? might be too restrictive. Try simplifying it:
{ "routes": [ { "src": "/api/(.*)", "dest": "dist/index.js" } ] }
Add a build script to ensure your TypeScript/source files are compiled:
{ "version": 2, "buildCommand": "npm run build", "builds": [ { "src": "dist/index.js", "use": "@vercel/node" } ], "routes": [ { "src": "/api/(.*)", "dest": "dist/index.js" } ] }
Try these changes and check your build logs in the Vercel dashboard to see if there are any build errors or if the dist/index.js file is being created properly.
Let us know how you get on!
1 Like
hey pauline, i was able to solve it and im deploying the main website, thanks for the help
1 Like
pawlean
(Pauline P. Narvas)
October 27, 2025, 2:13pm
7
Great to hear what worked for you!
system
(system)
Closed
November 10, 2025, 2:14pm
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.