historyApiFallback: true 對應(yīng)的 nginx 配置
這個設(shè)置用于自動將404響應(yīng)跳轉(zhuǎn)到首頁入口文件 index.html。
webpack 配置如下:
module.exports = {
//...
devServer: {
historyApiFallback: true
}
};
部署到服務(wù)器上時 nginx 的配置如下:
server {
listen 80;
server_name 172.20.47.16;
location / {
root /usr/share/nginx/html/console;
try_files $uri $uri/ /index.html; # 加上這一行即可
}
access_log /var/log/nginx/console_access.log main;
error_log /var/log/nginx/console_error.log;
}
參考:
https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback
http://www.rzrgm.cn/zph666/p/11468883.html
浙公網(wǎng)安備 33010602011771號