Docker URL when appended with angular route gives 404

Hi, I have an application which is deployed to docker with nginx. When, we route to default docker path i.e. docker.com/4200, it lands to landing page of angular application. However, when we try to directly navigate to some other route of the application like docker.com/4200/dashboard, then it gives 404 Not Found error.

Can someone please help what am I missing and how to make it work. Thanks in advance.

It depends on the application and your Nginx settings. We can’t really suggest a solution without knowing your configuration.

And one thing I don’t understand. Is docker.com in your url is just an example or this is actually the domain you are using for your application?

IIRC NginX needs some configuration to server Angular-applications correctly. See this SO-post (among others available) using the try_files to solve this issue:

docker.com is just an example.
My URL is like: http://docker-manager..com:49193/

My dockerFile:
FROM node:14.17-alpine as base

ADD package.json /frontend/package.json

ADD package-lock.json /frontend/package-lock.json

WORKDIR /frontend

RUN npm ci --unsafe-perm

ADD . /frontend

RUN apk update && apk add git

RUN npm run build --prod --output-hashing=all

FROM nginx:alpine

COPY --from=base /frontend/dist /usr/share/nginx/html

ADD nginx.conf .

EXPOSE 80

CMD [“/bin/sh”, “-c”, “envsubst < nginx.conf > /etc/nginx/conf.d/default.conf && nginx -g ‘daemon off;’”]

nginx.conf:
server {
listen 80;
listen [::]:80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

}

My angular app index.html file
<!doctype html>

In my local everything works fine, but it is only the docker deployed version which when entered with route gives 404