KCORS Setup
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
};
The reason I'm asking is because the kcors npm package reports using it using another configuration technique:
npm install @koa/cors@2 --save
and then app.use(cors({confg}))
Stale issue message
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.