DEV Community

Cover image for How to Resolve the 404 Error After Deploying the NodeJS in Vercel
Shyam1806
Shyam1806

Posted on

How to Resolve the 404 Error After Deploying the NodeJS in Vercel

Step 1. Check the Project Structure & File Structure
Step 2.Give the proper file name
Step 3.Initally I gave the file name as server.js for that it will throw the particular 404 Error. After I Changed the entry point of the API.I renamed the file name as Index.js.
Need to add Vercel.json in Your Project and i have attached image for refference.Check it

Image description

Inside the Vercel.json Need to setup the source directory. For that I have attached an Code below. Check it.
{
"version": 2,
"builds": [
{
"src": "./index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/"
}
]
}

Once this setup has been done then the code has been pushed in your GitHub and check the vercel deployment. Now u Can resolve the 404 error.Once successfully completed the 404 error you can visible like the below image

Image description

Image description

Now the above second image like you appear you can use the backend API URL In your project.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay