Skip to content

Instantly share code, notes, and snippets.

@joyblanks
Created August 19, 2019 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyblanks/7414ea434ab87b8ce1a3ec720ea9effe to your computer and use it in GitHub Desktop.
Save joyblanks/7414ea434ab87b8ce1a3ec720ea9effe to your computer and use it in GitHub Desktop.
Angular Proxy Config, when API's dont support CORS
// 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