【发布时间】:2023-01-30 05:30:55
【问题描述】:
我在 http://localhost:8050/ 上有一个 UI 应用程序,在 http://foo.local.bar.com 上有一个 api 服务器。
我直接登录到服务器,但是当我获取 GET 方法 http://foo.local.bar.com/myapi/api/goo/maa 时,我也需要 UI 将 cookie 发送到服务器。
在我的配置 json 中,我添加了 devServer 和代理,但它似乎不起作用:
devServer: {
proxy: {
'/api/*': {
"target": "http://foo.local.bar.com",
logLevel: 'debug',
secure: false,
changeOrigin: true,
withCredentials: true,
cookieDomainRewrite: "localhost",
onProxyReq: proxyReq => {
console.log("onProxyReq 1 !!!!!!!!") // I don't see any console logs, so I also think the proxy doesn't "catch" my request...
proxyReq.setHeader("Cookie", ".MYCOOKIE=123445");
console.log("onProxyReq 2 !!!!!!!!", proxyReq)
}
}
}
},
但我仍然收到“此请求的授权已被拒绝”。 401 错误。
有任何想法吗?我试过了,就像,一切...
【问题讨论】:
标签: node.js webpack-dev-server