1 min readSep 11, 2019
For some folks who will get in trouble with refresh the angular page and get a 404.
update the Dockerfile:
# base image
FROM node:latest as node
# set working directory
WORKDIR /app
# install and cache app dependencies
COPY . .
RUN npm install
RUN npm run build --prod
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/* && rm -rf /etc/nginx/nginx.conf
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY --from=node /app/dist /usr/share/nginx/html
and create a .nginx.conf at your root project folder with
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;
}
}
}
that will solve the issue of 404 when you are in a know page after refresh