Closed
Description
Has the cors configuration for routing controllers using koa changed?
Using the method found on the github page, I'm no successfully enabling cors and am quite unsure if the method to setup cors has changed.
Is the following still the correct way to setup cors for KOA and Routing Controllers?
this.app = await createKoaServer({
cors: this.getCorsConfiguration(),
controllers: [
IndexController
],
routePrefix: process.env.HTTP_BASEPATH,
classTransformer: true
});
Here is the configuration:
return {
origin: (ctx: koa.Context) => {
this.dlogger.log(`[NODE] Verifying cors`);
const whitelist: string[] = this.getCorsOriginWhitelist();
const requestOrigin = ctx.request.headers.origin;
if (!(whitelist.indexOf(requestOrigin) > -1)) {
return requestOrigin;
}
return false;
},
allowMethods: this.getCorsAllowedMethods(),
allowHeaders: this.getCorsAllowedHeaders(),
maxAge: 60
};