BlogRouting

404 Not Found when I refresh a React page.

A single-page app changes the address in the browser without asking the server. On refresh, the server must return index.html.

How the Agent API works
What you see
404 Not Found
  • What it meansThe server has no file for the route
  • On AntideployPaths without an extension get index.html
  • Still 404Check for a dot, or your own server
  • Missing assetsA file with an extension is a real 404

What it means

In a single-page app, a router such as React Router changes the address without asking the server. If you open /dashboard directly, or refresh on it, the browser asks the server for a file called dashboard. There is none. The server has to return index.html and let your app take over.

What Antideploy does

The server that hosts a static site or a built single-page app returns index.html for any address that has no file extension. A route such as /dashboard loads your app, and its router takes over. A missing file with an extension, such as a missing logo.png, returns a real 404. If your project has a 404.html, that page is shown for those.

If you still get a 404

  • The route has a dot in it. A path such as /reports/v1.2 looks like a file because of the .2. Avoid dots in route paths.
  • Your project is an app with its own server. Then your server decides. Make it return index.html for routes it does not know.
  • You use a Dockerfile with a web server. If your Dockerfile runs a web server such as nginx, its configuration decides. Add a rule that falls back to index.html.
  • A wrong base path. If your app is built to live under a folder, assets and links break. Set the base path to /, for example base: "/" in a Vite config.

01Questions

Routing questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Do I need a _redirects file or a rewrite rule?

Not on Antideploy's static hosting. The fallback to index.html is built in.

Does Next.js need this?

No. A Next.js app runs its own server and handles its routes.

Does this error cost anything?

No. It is a page in your app, and a deploy is not involved.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.