historyApiFallback: true 对应的 nginx 配置
时间:2020-04-13 21:58:45
收藏:0
阅读:513
这个设置用于自动将404响应跳转到首页入口文件 index.html。
webpack 配置如下:
module.exports = {
//...
devServer: {
historyApiFallback: true
}
};
部署到服务器上时 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
https://www.cnblogs.com/zph666/p/11468883.html
原文:https://www.cnblogs.com/keithtt/p/12693382.html
评论(0)