46

内网穿透访问Vue项目的时候出现Invalid Host header解决办法

 4 years ago
source link: http://mushiming.top/mushblog/archives/995
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
4 次查看

出现Invalid Host header解决办法

内网穿透

适用场景:

在本地的Vue-cli3项目, 需要其他人浏览. 如果没有外网的服务器, 可以把自己的电脑当做服务器. 这时候需要外网的人能访问到自己的电脑.

内网穿透工具:

这个有很多, 比如花生壳, Frp, ngrok, 我用的是国内的sunny-ngrok. 使用非常简单, 根据官网操作就可以.

Invalid Host header

当启动了sunny-ngrok的客户端以后, 就这个用sunny-ngrok提供的域名, 来访问本地的127.0.0.0:8080(端口自己设置), 如果Vue项目启动, 外网就可以通过域名来访问Vue项目. 但是如果出现 Invalid Host header, 需要设置一下

vue-cli3中:

// vue.config.js文件中

module.exports = {

devServer: {

disableHostCheck: true

}

}

赞赏

fIr2AfU.jpg!web 微信赞赏 JBfe2q7.jpg!web 支付宝赞赏

BVfeeun.png!web

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK