# Angular (production): Cannot GET /dashboard — 404 when refreshing or opening a deep link

**Code:** `Cannot GET /route on refresh` · **Category:** Angular · **Seen on:** Angular, Nginx, Apache

The web server only knows `index.html`; a direct request to `/dashboard` is not a file, so it returns 404 instead of letting Angular's router handle the URL.

## Meaning

Angular is a single-page app: every path must return `index.html` and the router takes over in the browser. Configure the server (Nginx `try_files`, Apache rewrite, Express `*`, S3/CloudFront error document) to fall back to `index.html`, or use hash routing as a quick workaround.

## Common causes

- Nginx/Apache not configured with an SPA fallback
- Express serving `dist` without a catch-all route
- S3/CloudFront with no 403/404 → `/index.html` rewrite
- Wrong `<base href>` in a sub-folder deployment
- Firebase/Netlify/Vercel without a rewrite rule

## Quick fix

1. Add the fallback to `index.html` on your server
2. Check `<base href>` matches the deployment path
3. Temporary: `provideRouter(routes, withHashLocation())`

## Detailed fix by platform

### Nginx

1. `location / { try_files $uri $uri/ /index.html; }`

### Apache

1. `RewriteEngine On` `RewriteCond %{REQUEST_FILENAME} !-f` `RewriteCond %{REQUEST_FILENAME} !-d` `RewriteRule ^ index.html [L]`

### Angular

1. `ng build --base-href /app/` when the app is not served from the domain root

## Code examples

### SPA fallback

```nginx
server {
  root /var/www/app/browser;
  index index.html;
  location / {
    try_files $uri $uri/ /index.html;     # unknown paths go to Angular's router
  }
}
```

## How to diagnose

1. **Server** — Which web server serves the build?
2. **Fallback** — Rule to index.html present?
3. **Base** — Correct base href?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/refresh-404-cannot-get-route)
