skip to Main Content

I started a very simple project using only Html, Css and Vanilla JS. When I deployed it to Vercel, first it worked and then it just gave me an error (404 Not Found). As the project is still in its infancy, I started from scratch, created a new repo and tried to deploy it again, but the same error still occurs.
As a note, my old projects from other repos are still visible. What could be the possible error?

Link to Preview

I’ve already tried restarting the project from scratch, with a new repo.

I have a new Mac and since I started using it, Vercel doesn’t work. However, my old projects that I only have on Github are still visible on Vercel.

2

Answers


  1. Chosen as BEST ANSWER

    I needed this vercel.json file:

        {
      "version": 2,
      "builds": [
        {
          "src": "index.html",
          "use": "@vercel/static"
        },
        {
          "src": "styles/*",
          "use": "@vercel/static"
        },
        {
          "src": "scripts/*",
          "use": "@vercel/static"
        }
      ],
      "routes": [
        {
          "src": "/(.*)",
          "dest": "/index.html"
        }
      ]
    }
    

    and also to install vercel:

    npm install -g vercel
    

    The result isn't what I expected it still looks total different than my local version, but I don't see the 404 anymore:


  2. I think you are missing the routing of vercel.json. create a vercel.json file in the root of the repo with the following content

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

    and push to the repository.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search