chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.7k stars 834 forks source link

can't rewrite request cookie #240

Open stephenliu1944 opened 6 years ago

stephenliu1944 commented 6 years ago

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?

tanyoumei commented 6 years ago

me two

shizigou9000 commented 6 years ago

me too

mimimile commented 5 years ago

me too

mimimile commented 5 years ago

@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'