Created
March 2, 2020 13:17
-
-
Save synaptic-cleft/8a52493117f7e1dcf7193e3b0034a1e0 to your computer and use it in GitHub Desktop.
CORS workaround in stub server for axios calls with Authorization header for access token
This file contains 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 express = require('express') | |
const app = express() | |
// !!! This is a workaround for local development only. NEVER DO THIS ON PRODUCTION !!! SOC would kill you. And your family. | |
let allowCrossDomain = function(req, res, next) { | |
res.header('Access-Control-Allow-Origin', 'http://localhost:5000') | |
res.header('Access-Control-Allow-Headers', 'Authorization') | |
res.header('Access-Control-Allow-Credentials', 'true') | |
next() | |
} | |
app.use(allowCrossDomain) | |
// Actual handling of requests would go here... | |
app.listen(3001) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment