Hello guys, i'm using POSTMAN to make a request on my serve but it is been blocked by cors. Does someone knows how to solve this? doesnt make sense cuz postman is not a browser. the origin it is been undefinedThis is my code: ts private middlewares (): void { this.express.use(express.json()) const whiteList = ['http://127.0.0.1:8020', 'http://localhost:5000'] const corsOptions = { origin: (origin, callback) => { if (!!origin && whiteList.indexOf(origin) !== -1) { callback(null, true) } else { callback(new Error('Not allowed by CORS')) } } } this.express.use(cors(corsOptions)) }
Submitted December 31, 2019 at 07:29PM by danilosilvadev
No comments:
Post a Comment