spooky particles

Tells your coding agent when an app you shipped breaks.Spooky Particles

Spooky doesn't catch this one.

Vercel 404 not found on refresh: why it happens and the fix

A 404 on refresh usually means the app routes pages in the browser and Vercel has no file at that address. Add a rewrite that sends every path to index.html (for a single page app), or use your framework's own routing, then redeploy.

Why does my Vercel app show 404 when I refresh the page?

A client-side router changes the address in the browser, but a refresh sends that address to Vercel. Vercel looks for a file at the path, and a single page app has none there, so it returns 404 NOT_FOUND.

How do I fix it?

For a Vite single page app, Vercel's Vite guide says in Using Vite to make SPAs that deep links do not work by default. Create vercel.json at the project root with this rewrite:

json
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

If cleanUrls is true, the same guide says to leave off the file extension, so the destination becomes / instead of /index.html. See the vercel.json rewrites reference for the project configuration format. Then redeploy.

What if I use Next.js or another framework?

The Vite guide says framework-based projects such as SvelteKit should prefer their framework's own method. Use the framework's routing and check that the page or route file exists.

For any framework, Vercel's NOT_FOUND page lists checking the URL for typos, confirming that the deployment exists, reviewing the deployment logs, and checking permissions. The Vercel 404 NOT_FOUND guide walks through those checks.

If the custom domain itself does not load, check the Vercel DNS issue steps.

What can I paste into my coding agent?

text
Find which router or framework this app uses and check whether the project has a vercel.json file. Propose the minimal rewrite or framework routing fix for a 404 that appears on page refresh. Do not change any other files and do not redeploy. I will review the fix and redeploy.

Related

For other missing-page causes, see Vercel 404 NOT_FOUND and Vercel DEPLOYMENT_NOT_FOUND. The Vercel deployment errors list and Vercel deployment failed guide cover wider deployment problems. Automate fixes explains the coding-agent workflow, and VibeOps covers keeping shipped apps running.