問題:使用花生殼內(nèi)網(wǎng)穿透只返回304,invalid host header
原因:新版的webpack-dev-server出于安全考慮,默認檢查hostname,如果hostname不是配置內(nèi)的,將中斷訪問。
解決: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,
},