[AXIOS] 📚 CORS 쿠키 전송하기 (withCredentials 옵션)
[WEB] 📚 CORS 개념 💯 완벽 정리 & 해결 방법 👏
var allowlist = ['<http://game.jerrykang.com>', '<http://admin.jerrykang.com>']
var corsOptionsDelegate = function (req, callback) {
var corsOptions;
if (allowlist.indexOf(req.header('Origin')) !== -1) {
corsOptions = { origin: true, credential: true } // reflect (enable) the requested origin in the CORS response
} else {
corsOptions = { origin: false } // disable CORS for this request
}
callback(null, corsOptions) // callback expects two parameters: error and options
}
app.use(cors(corsOptionsDelegate));
let corsOptions = {
origin: ['<http://game.jerrykang.com>', '<http://admin.jerrykang.com>'],
credentials: true
}
app.use(cors(corsOptions));