The Refresh Problem
Angular is a single-page app: only index.html exists. When a user opens /products/5 directly, the server looks for a file called products/5, finds nothing and returns 404. The server must send index.html for unknown paths so the Angular router can take over. This is called SPA fallback.
Nginx
Docker (Multi-Stage Build)
my-app with your project name from angular.json. In some versions the output folder is dist/<name> without browser for client-only builds, so check your dist folder after building.
Firebase Hosting
Netlify
- Connect your Git repository on netlify.com
- Build command:
ng build - Publish directory:
dist/my-app/browser - Add a file
public/_redirectscontaining:/* /index.html 200
Vercel and GitHub Pages
| Host | Notes |
|---|---|
| Vercel | Add vercel.json with a rewrite of all paths to /index.html |
| GitHub Pages | Use --base-href /repo-name/ and copy index.html to 404.html for fallback |
| S3 + CloudFront | Set the 404 error response to return /index.html with 200 |
Deploying an SSR App
SSR apps need a Node.js server, not just static files. Run node dist/my-app/server/server.mjs on a VM, a container platform or a service that supports Node. Fully prerendered sites (SSG) can still go to static hosting.
API and CORS
- Either serve the API from the same domain (reverse proxy
/apito your backend) - Or enable CORS on the API for your site's domain only
- Use HTTPS everywhere
Conclusion
An Angular build is static files plus an SPA fallback to index.html. Nginx or Docker works anywhere, Firebase and Netlify are easy, and SSR needs a Node server.
<app>/browser + SPA fallback; Nginx, Docker, Firebase, Netlify.

