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

(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
    },

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

相关推荐
我不会插花弄玉16 小时前
5.应⽤层协议HTTP【由浅入深-网络】
http
如夏倾城2 天前
QUIC——HTTP/3 的唯一底层传输协议 及 0-RTT恢复
网络·网络协议·tcp/ip·安全·http
Thanks_ks3 天前
HTTPS:浏览器地址栏那把锁的工作原理
http·网络安全·https·tls·加密算法·数字证书·中间人攻击
杨凯凡3 天前
Spring Boot 大文件下载如何实现断点续传?HTTP Range、206 与 416 实战
spring boot·后端·http
FungLeo4 天前
成为全栈·Vue 管理后台篇·用 fetch 建一层可控的请求内核
前端·javascript·vue.js·http·fetch·formdata·接口封装
wuyk5554 天前
Spider-第03讲-HTTP速通与读懂响应
网络·爬虫·网络协议·http
杨凯凡5 天前
Spring Framework 7 HTTP Interface 实战:声明式 RestClient、超时与测试
java·spring·http
CodeYp20195 天前
第11讲:应用层协议 HTTP
linux·http
Thanks_ks6 天前
HTTP 请求方法与 RESTful 接口设计:GET 和 POST 到底怎么用
http·api·restful·状态码·get·post·接口设计
LK_077 天前
【FastAPI】基础篇 01|开始之前:API、HTTP 与 FastAPI 到底是什么
网络协议·http·fastapi