内网穿透 vue 返回 invalid host header
2019年03月17日 16:05:29 renzhehongyi 阅读数:1926收起
个人分类: 互联网Vue
问题:使用花生壳内网穿透只返回304,invalid host header
原因:新版的webpack-dev-server出于安全考虑,默认检查hostname,如果hostname不是配置内的,将中断访问。
解决:webpack.dev.conf.js添加配置 disableHostCheck: true,
-
devServer: { -
clientLogLevel: 'warning', -
historyApiFallback: { -
rewrites: [ -
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, -
], -
}, -
hot: true, -
contentBase: false, // since we use CopyWebpackPlugin. -
compress: true, -
host: HOST || config.dev.host, -
port: PORT || config.dev.port, -
open: config.dev.autoOpenBrowser, -
overlay: config.dev.errorOverlay -
? { warnings: false, errors: true } -
: false, -
publicPath: config.dev.assetsPublicPath, -
proxy: config.dev.proxyTable, -
quiet: true, // necessary for FriendlyErrorsPlugin -
watchOptions: { -
poll: config.dev.poll, -
}, -
disableHostCheck: true, -
},
disableHostCheck: true, },
