You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the proxy options in webpack configuration.
My webpack dev server is running at localhost:8888 and my backend is at localhost:8000.
What I was expecting is that all the HTTP HEADERS sent to the webpack dev server would have been forwarded to the proxy server at localhost:8000
Actual behavior
Actually some HTTP HEADERS are missing, at least the one I am interested in, that is: http-x-requested-with XMLHttpRequest. This header is never sent to the destination server and I'm wondering if it is by design or a bug.
The only way to make this work is to manually add this header in the proxy section of the webpack config headers: {'http-x-requested-with' : 'XMLHttpRequest' }
devServer: {contentBase: "./public",// do not print bundle build statsnoInfo: true,// enable HMRhot: true,// embed the webpack-dev-server runtime into the bundleinline: true,// serve index.html in place of 404 responses to allow HTML5 historyhistoryApiFallback: true,port: PORT,host: HOST,proxy: {'/api/*': {target: 'http://localhost:8000',pathRewrite: {'^/api' : ''},secure: false,changeOrigin: true,// manually adding this will add the header back and send it to the destination server// headers: {'http-x-requested-with' : 'XMLHttpRequest' }}}},
The text was updated successfully, but these errors were encountered:
As side note, with the same configuration when the destination server sends back a response 302 -> the proxy send back to the client a 404 error!! What am I doing wrong?
Sorry, my mistake, I was not sending the 'x-requested-with' : 'XMLHttpRequest' in the first place, I was expecting Axios to do this automatically but I was wrong.
Expected behavior
I'm using the proxy options in webpack configuration.
My webpack dev server is running at
localhost:8888
and my backend is atlocalhost:8000
.What I was expecting is that all the HTTP HEADERS sent to the webpack dev server would have been forwarded to the proxy server at
localhost:8000
Actual behavior
Actually some HTTP HEADERS are missing, at least the one I am interested in, that is:
http-x-requested-with XMLHttpRequest
. This header is never sent to the destination server and I'm wondering if it is by design or a bug.The only way to make this work is to manually add this header in the proxy section of the webpack config
headers: {'http-x-requested-with' : 'XMLHttpRequest' }
Setup
proxy middleware configuration
server mounting
Webpack devserver config
The text was updated successfully, but these errors were encountered: