当前位置: 首页 > 工具软件 > proxy-test > 使用案例 >

http-proxy-middleware 请求代理get/post

巢睿
2023-12-01

使用场景:前端需要自己管理、发布正式包。前端页面域名与后端借口不一致

const express = require('express')
const path = require('path')
const app = express()
const proxy = require('http-proxy-middleware')
const session = require('express-session');
const router = express.Router();



app.use(express.static(path.join(__dirname, 'dist')))

app.use('/api', proxy({
  target: 'http://*.*.*.*:8080',
  changeOrigin: true
}))

处理post请求:https://blog.csdn.net/lin819397746/article/details/96107376

 类似资料: