I've already configured cors
in my nodejs application as follow:
cors = require('cors');
var whitelist = ['http://first.url', 'https://test.cloudfront.net']
var corsOptions = {
origin: function (origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
}
router.get('/home', cors(corsOptions), controller.index);
It's working and fetch data from nodejs app from http://first.url
but when I tested with https://test.cloudfront.net
, it's not working and return following error.
XMLHttpRequest cannot load https://server.cloudfront.net/api/app/home. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://test.cloudfront.net' is therefore not allowed access.
Please let me know how come that error is return. Because of some configuration is missing in cloudfront?
via ppshein
No comments:
Post a Comment