'Problem with mime type with combination of Nginx and angular

I had built angular project with following command

npm run build --prod --base-href=./ --deploy-url=./

I am having nginx config as follows:

worker_processes 4;

events { worker_connections 1024; }

http {
    server {
        listen 80;
        root  /usr/share/nginx/html;
        include /etc/nginx/mime.types;

        location / {
            try_files $uri /index.html;
        }
    }
}

Following urls are working with nginx local server

http://localhost:80

http://localhost:80/cart

But when I try to access

http://localhost:80/order/20

I am getting an following error:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source