Reputation: 11
my back end is node js, i set cors setting like that :
const whitelist = ['https://backend.example.com', 'https://example.com']
const corsOptions = {
credentials: true,
origin: function(origin, callback) {
console.log('Received origin:', origin, 'callback:', callback);
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('CORS ERROR'))
}
}
}
this.#app.use(cors(corsOptions))
my back end run in subdomain: backend.example.com
When I send request from example.com (with axios in front end(nextjs)) i can receive response. but when send request from subdomain(with swagger) I received cors error. How can I solve it?
I change code several time but I can't fix the error.
Upvotes: 1
Views: 204