我使用nginx和vite来docker vue.js。但是,当我设置基本路径时,浏览器屏幕变为空白。返回/test/index html,但/test/assets/something. js和css也返回html。我如何重写vite + base + nginx,以便正确显示以下URL?
http://localhost:808/test/index
vite.confign.ts
base: '/test/',
default.conf
server {
listen 8080 default_server;
server_name "";
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log main;
location ~ ^/assets/(.*)$ {
proxy_set_header X-Forwarded-For $remote_addr;
root /home/vue_server/assets/$1;
try_files $uri $uri/ /index.html;
}
location / {
proxy_set_header X-Forwarded-For $remote_addr;
root /home/vue_server/;
try_files $uri $uri/ /index.html;
}
}
1条答案
按热度按时间mnowg1ta1#
试试这个: