这边使用PdfShowcase 作为anguar17为fornt-end的pdf展示插件,本地npm start启动都没有任何问题,但是部署到nginx时候就报这个错,然后pdf也无法加载出来。
这是我整个的nginx的配置,======================================就是需要增加的配置,保存之后sudo systemctl reload nginx 重启nginx就解决了
server {
listen 9000;
server_name 0.0.0.0;
root /home/deploy-user/project_code/target/classes/static; # 这里指定了你的项目文件所在的目录
index index.html index.htm; # 默认索引文件
# 其他配置...
location /api {
proxy_pass http://localhost:5000;
}
location / {
try_files $uri $uri/ /index.html;
}
#======================================
location ~* \.mjs$ {
types { }
default_type application/javascript;
add_header Cache-Control "public, max-age=31536000";
}
gzip on;
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
#======================================
# 其他可能的配置,如SSL等...
# 其他location块...
}