404 error after deployment

Hello, I have an issue with my express app

When i run it locally, it’s good
But after deployment on vercel, it’s giving a 404 error (Not Found). I have checked everything, my env variables are good, my api keys are good, actually everything is good, even the request to server is sent, the problem is from server. Please help vercel staff, new to backend…

Website link: https://geomapz.vercel.app
GitHub link: GitHub - Tousif-Rehman/GeoMapz: A Geolocation Service

Hi, @t-rexman! It looks like your deployment is up and running now. :smile:

Want to share what you did to fix the issue?

Really?

It’s the same for me…
Uploading: 17291692462686778020379446885778.jpg…

Yeah, I see this! :eyes:

Can you try in incognito?

Oh, apologises. I thought the error you were referring to was a deployment.

I’ll take a closer look!

1 Like


This is when I run locally…

Any update mam??

I’m trying my best from my side too…

Thanks for sharing the repo. That was very helpful to see.

It looks like the project uses Express.js, which needs a bit of adjustment to work in a serverless environment. Files in the /api directory are automatically turned into serverless functions. Files outside of that directory are not automatically used as Vercel Functions unless some extra configuration is done to make it happen.

For most projects, I recommend using the /api folder option. It’s the least fussy solution and it’s what I most often use for my own projects.

This is a pretty quick change to make in your case. First, you would need to create a /api folder and move the index.js file into it. Then update the vercel.json file with the following:

{
    "version": 2,
    "rewrites": [
        {
            "source": "/(.*)",
            "destination": "/api"
        }
    ]
}

There’s also a guide that can help with this if you want to see a more complete example: Using Express.js with Vercel

2 Likes

Thanks Amy, it’s working… :100:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.