前后端跨域/ 同时运行两个项目

(1)后端配置端口

复制代码
server:
  port: 90

(2)前端 配置跨域资源共享(CORS)

复制代码
devServer: {
  disableHostCheck: true,
  port: 8088,
  proxy: {
    '/openapi': {
      target: 'http://192.168.31.109:90',
      ws: false,
      changeOrigin: true
    },

其它信息

默认端口80通常用于HTTP协议,是Web服务器默认监听的端口

所以在后端端口配置为80的时候,前端可以不写,就像下面这样

复制代码
devServer: {
  disableHostCheck: true,
  port: 8088,
  proxy: {
    '/openapi': {
      target: 'http://192.168.31.109',
      ws: false,
      changeOrigin: true
    },

所以同时运行两个项目的话,需要 更改后端的端口,和前端对应的端口配置

相关推荐
2301_803554521 天前
https
网络协议·http·https
AuroraDPY2 天前
计算机网络:HTTP协议
网络协议·计算机网络·http
小马_6662 天前
[好记性不如烂笔头]RT_Thread http ota升级踩坑笔记(CRC校验不通过)
笔记·物联网·网络协议·http
心一信息2 天前
http与https的详细介绍
网络协议·http·https
r***86982 天前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http
想不明白的过度思考者2 天前
Cookie与Session深度解析:原理、区别
网络·http·客户端·cookie·session·服务端
谢尔登2 天前
HTTPS 究竟比 HTTP 好在哪?
http·https·ssl
k***3882 天前
Node.js HTTP模块详解:创建服务器、响应请求与客户端请求
服务器·http·node.js
i***48613 天前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http