Created
April 1, 2019 15:49
-
-
Save dominictobias/9fd97c6a839c79a88f1d3beeb515e5b2 to your computer and use it in GitHub Desktop.
setupProxy.js for http->https with cookies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const proxy = require('http-proxy-middleware'); | |
// Execute `copy(document.cookie)` in the console on the proxy site | |
// and paste into this string. | |
const cookies = ''; | |
module.exports = function(app) { | |
app.use(proxy('/api', { | |
changeOrigin: true, | |
cookiePathRewrite: true, | |
cookieDomainRewrite: true, | |
secure: false, | |
rejectUnauthorized: false, | |
onProxyReq: (proxyReq, req, res) => { | |
proxyReq.setHeader('Cookie', cookies); | |
}, | |
target: 'https://proxysite.com/', | |
})); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for code snippet . I have tried the above code but it was giving error. Then i fixed that error with following piece of code.