$ cat <<EOF > nginx.conf
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
}
EOF
$ cat <<EOF > Dockerfile
FROM node:18-alpine AS build
...
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
COPY --from=build /app/dist .
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
EOF
This fixes the 404 Not Found issue when you reload the page in the browser.