Skip to content

Commit

Permalink
fix: config.proxy 非 / 代理时, host 不应是 / 的代理
Browse files Browse the repository at this point in the history
  • Loading branch information
wll8 committed Sep 18, 2021
1 parent ed8ca6b commit 4fd2b6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/dev/todo.md
Expand Up @@ -4,6 +4,7 @@
- [ ] doc: 如何更新 replayPort 返回的数据?
- 如果代理服务是 9000, 使用同样的参数再请求一下 9000 端口即可, 因为重放时的数据默认会从最新的请求记录中获取
## 功能
- [x] fix: config.proxy 非 `/` 代理时, host 不应是 `/` 的代理
- [ ] feat: 支持根据运行环境自动切换语言
- [ ] feat: 支持生成纯前端可用的 mock 数据
- [ ] feat: 接口 `:9005/api/getOpenApi/` 应变更为仅获取原样的 json, 而 `/getOpenApiWrap` 才是经过处理的
Expand Down
2 changes: 1 addition & 1 deletion server/proxy.js
Expand Up @@ -256,7 +256,7 @@ async function serverProxy({
TOKEN = req.get('Authorization') || TOKEN // 获取 token
},
onProxyRes: (proxyRes, req, res) => {
allowCors({res: proxyRes, req})
allowCors({res: proxyRes, req, proxyConfig: userConfig})
setHttpHistoryWrap({
config,
history: HTTPHISTORY,
Expand Down
6 changes: 4 additions & 2 deletions server/util/business.js
Expand Up @@ -1014,8 +1014,10 @@ function business() { // 与业务相关性的函数
// 'access-control-max-age': undefined,
// 'access-control-expose-headers': undefined,
})
req && setHeader(req, { // 一些服务器会校验 req 中的 referer, host
'referer': target,
req && setHeader(req, { // 一些服务器会校验 req 中的 referer referrer origin host
'referer': target, // referer 实际上是 "referrer" 误拼写
'referrer': target,
'origin': target, // 不应包含任何路径信息
'host': (new URL(target)).host
})
}
Expand Down

0 comments on commit 4fd2b6c

Please sign in to comment.