server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/vue/dist;
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
add_header "GET, POST, HEAD" always;
location /static {
alias /var/www/vue/dist/static/;
}
location /web/service {
if ($request_method = OPTIONS ) {
return 405;
}
rewrite ^/web/service/(.*)$ /$1 break;
try_files $uri $uri/ /index.html;
autoindex off;
index index.html;
}
}
I developed the frontend using vue. After the build, I try to load the page in /web/service, but the js file is not loaded.
I am getting a 404
error.
The built file is located under /var/www/vue/dist
and the configuration is as follows.
dist
-- index.html
-- static
-- css
-- js
-- font
The dist
file is structured like this.
The static subfiles are not loaded.
In the console window
GET https://{URL}/static/js/app.4d37ce819e144.js net::ERR_ABORTED 404 (Not Found)
output like this
But https://{URL}/web/service/static/js/app.4d37ce819e144.js
If you type in the address bar, the contents of the file are displayed.
I hope you can tell me how to configure nginx.