I have an issue with webpack-dev-server when it proxys to my prod env. The production server sends me 'set-cookie' header but it is an array and I don't see it in dev-server's response in the browser.
Also, when I debug I see a lot of headers coming from the prod server, but I have not all of them in the browser. How to make webpack-dev-server to bypass all the headers as is.
Thanks.
In many cases, headers should be automatically copied from the proxy response to the response sent to the browser by http-proxy-middleware. The default behavior of most proxy implementations is to forward headers.
But, you could intercept all of the responses from proxy with the headers and inspect/modify them.
proxy: {
"**": {
target: "http://localhost:8000", // Proxy to backend
changeOrigin: true,
secure: false,
// This handles responses
onProxyRes: function (proxyRes, req, res) {
// Get all headers from proxy response and write them out to console
Object.keys(proxyRes.headers).forEach((key) => {
console.log(`${key}: ${proxyRes.headers[key]}`);
});
}
},