http-proxy-middleware icon indicating copy to clipboard operation
http-proxy-middleware copied to clipboard

can't rewrite request cookie

Open stephenliu1944 opened this issue 7 years ago • 4 comments

I want to rewrite request cookie using following code, but didn't work.

proxy.on('proxyReq', function (proxyReq, req, res) { 
  proxyReq.setHeader('cookie', 'SESSION=123'); 
});

And is there a way to find API of proxyReq Object?

stephenliu1944 avatar Feb 12 '18 08:02 stephenliu1944

me two

tanyoumei avatar Mar 13 '18 10:03 tanyoumei

me too

shizigou9000 avatar May 16 '18 02:05 shizigou9000

me too

mimimile avatar Sep 29 '18 12:09 mimimile

@stephenliu1944 you should set headers Access-Control-Allow-Credentials

proxyRes.headers['Access-Control-Allow-Credentials'] = true
proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild'
proxyRes.headers['Access-Control-Allow-Methods'] = 'PUT, POST, GET, DELETE, OPTIONS'

mimimile avatar Sep 30 '18 07:09 mimimile