I've built an application with Angular 6 and I'm using the Angular 6 wildcard route for 404's. https://angular.io/guide/router#wildcard-route
I'm building the application into an index.html and a bunch of static files with the ng build --prod
command and I'm serving the application with nginx. The 404 page does not work when doing this. Is there something special I need to do to get nginx to use the Angular wildcard 404 page? A 404.html isn't actually generated when running ng build --prod
Edit
const appRoutes: Routes = [
{ path: '', component: LandingComponent },
{ path: 'changepassword', canActivate: [ AuthGuard ], component: ChangePasswordComponent },
{ path: 'resetpassword', component: ResetPasswordComponent },
{ path: 'resetpassword/:token', component: ResetPasswordPart2Component },
{ path: '**', component: PageNotFoundComponent }
]
Edit
To confirm, I understand that a 404.html page shouldn't be generated.
Edit
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
try_files $uri $uri/ /index.html;
}
}
}