前提是已经配置好了相应的外网和内网端口的映射

.公网ip和端口配置

vue项目启动之前对项目下:项目名/config/index.js 文件进行修改

原来的内容为:(位置在index.js的第16,17行作用)

 

    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined

 

修改为0.0.0.0 和8070端口:

    host: '0.0.0.0', // can be overwritten by process.env.HOST
    port: 8070, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined

VUE项目部署公网ip和端口以及使用域名访问配置

.使用域名+端口访问配置

没有配置的情况下通过域名加端口访问出现:

VUE项目部署公网ip和端口以及使用域名访问配置

在如下截图的位置加这个配置:

 

disableHostCheck: true,// 解决域名访问本地运行地址时出现Invalid Host header的问题 

 

VUE项目部署公网ip和端口以及使用域名访问配置

在此用:npm run dev  运行

此时用域名加端口访问正常

VUE项目部署公网ip和端口以及使用域名访问配置

 

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2021-09-27
  • 2021-04-16
  • 2022-01-17
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2021-04-22
  • 2021-10-04
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案