Access next.js static files inside docker & nginx

Viewed 264

My next.js blog application is inside a docker container. The container is accessible on port 5000.

Inside next.config, we have assetPrefix:'/blog' but the browser is unable to load the assets (CSS, JS, ...)

Here's the current nginx config:

server {
        server_name mydomain.com;

        location /blog/_next/static/ {
            alias /usr/src/app/_next/;
            sendfile on;
            sendfile_max_chunk 1m;
        }

        location / {
            proxy_pass    http://localhost:3000;
        }

        location /blog/ {
            proxy_pass    http://localhost:5000;
        }
}


0 Answers
Related