# Browser: Cannot GET /users/42 — refreshing a Vue Router history-mode page returns 404

**Code:** `404 on page refresh (history mode)` · **Category:** Vue · **Seen on:** Vue, Nginx

In history mode the server must serve `index.html` for all routes; otherwise direct URLs/refreshes hit non-existent files.

## Meaning

Add an SPA fallback: Nginx `try_files $uri $uri/ /index.html;`, Apache `.htaccess` rewrite to `index.html`, Netlify `_redirects` `/* /index.html 200`, Firebase `rewrites`, S3/CloudFront custom error response 404→200 `/index.html`. Or use `createWebHashHistory`. Set `base` if hosted in a subfolder.

## Common causes

- Static server without fallback
- Wrong base (subdirectory deploy)
- Nginx try_files missing
- CDN returning 404 for unknown paths
- Assets requested relative to route path

## Quick fix

1. Nginx: `location / { try_files $uri $uri/ /index.html; }`
2. Netlify `_redirects`: `/* /index.html 200`
3. Set `base`/`publicPath` correctly or use hash history

## Detailed fix by platform

### Nginx

1. `location / { root /var/www/app; try_files $uri $uri/ /index.html; }`

## How to diagnose

1. **Server** — Fallback?
2. **Base** — Subfolder?
3. **CDN** — Error rewrite?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/vue/vue-router-history-mode-404-on-refresh)
