这是我的nginx. conf. CSS和JS在这个文件夹里
/usr/share/nginx/static/css
/usr/share/nginx/static/js
/usr/share/nginx/static/media
location ~ (css|js|img) {
root /usr/share/nginx/html;
try_files $uri $uri/ =404;
}
location / {
root /usr/share/nginx/html;
}
但我收到了这个错误
Failed to load resource: the server responded with a status of 404 (Not Found) 2.0fe3a37f.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found) 2.0a7ada56.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.e5e7c1e6.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.8a3eed81.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) 2.0a7ada56.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.8a3eed81.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) 2.0fe3a37f.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.e5e7c1e6.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.e5e7c1e6.chunk.css:1
1条答案
按热度按时间0ejtzxu11#
我有同样的问题,只有以下帮助我(我使用FastApi项目,并部署在AWS EC2服务器):
根路径取自以下信息(只需复制此命令到您的终端):
添加根路径,这是从上面的信息,到nginx.conf:
在css: