Created
August 19, 2019 05:20
-
-
Save joyblanks/7414ea434ab87b8ce1a3ec720ea9effe to your computer and use it in GitHub Desktop.
Angular Proxy Config, when API's dont support CORS
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
// README: check the cookie from request headers in browser and replace this. | |
const cookie = "<Copy a cookie from a request that happens in your API when deployed>"; | |
const target = "https://<tenant>.sharepoint.com"; | |
const PROXY_CONFIG = { | |
"/test/_layouts/*": { | |
"target": target, | |
"secure": false, | |
"changeOrigin": true, | |
"bypass": function (req, res, proxyOptions) { | |
req.headers["origin"] = target; | |
req.headers["cookie"] = cookie; | |
} | |
}, | |
"/test/_api/*": { | |
"target": target, | |
"secure": false, | |
"changeOrigin": true, | |
"bypass": function (req, res, proxyOptions) { | |
req.headers["origin"] = target; | |
req.headers["cookie"] = cookie; | |
} | |
}, | |
"/_api/*": { | |
"target": target, | |
"secure": false, | |
"changeOrigin": true, | |
"bypass": function (req, res, proxyOptions) { | |
req.headers["origin"] = target; | |
req.headers["cookie"] = cookie; | |
} | |
} | |
} | |
module.exports = PROXY_CONFIG; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment