Next.js Discord

Discord Forum

Express.js route working locally but not on Vercel 404 error

Unanswered
West African Lion posted this in #help-forum
Open in Discord
Original message was deleted.

13 Replies

Avatar
You are using the wrong vercel config
{ "version": 2, "rewrites": [{ "source": "/(.*)", "destination": "/api" }] }
I deployed a express app to vercel today, and it workde
You just need a api/index.ts|js file
Avatar
West African Lion
I have that file Ill try using reqrites and let you know
I dont know how I missed the rewrites
I must of used it in a wrong way and switched to routes
Its not working 😦
{
    "version": 2,
    "builds": [
        {
            "src": "src/app/api/index.js",
            "use": "@vercel/node"
        },
        {
            "src": "package.json",
            "use": "@vercel/next"
        }
    ],
    "rewrites": [
        {
            "source": "/(.*)",
            "destination": "/api"
        }
    ]
}
src\app\api\index.js is the path
The error has changed to a 500 internal server error and it shows vercel's error page
this is the url incase it helps
https://summonerscard.com/api?url=https%3A%2F%2Fraw.communitydragon.org%2Flatest%2Fplugins%2Frcp-be-lol-game-data%2Fglobal%2Fdefault%2Fv1%2Fchampion-summary.json
Avatar
West African Lion
Cannot find module 'styled-jsx/style'
Require stack:
- /var/task/node_modules/next/dist/server/require-hook.js
- /var/task/node_modules/next/dist/server/next.js
- /var/task/src/app/api/index.js
Did you forget to add it to "dependencies" in package.json?
Node.js process exited with exit status: 1. The logs above can help with debugging the issue. I was getting this error even tho I have added it to the dependencies