Closed leonardo2204 closed 3 years ago
This happened to me only when I did not remove the default express router und then two router-"middlewares" have been excuted for the same route.
Yeah, it seems to be the problem. In my case, changing the order solved the problem:
const appCopy = useExpressServer(this.app, {
routePrefix: config.express.routePrefix,
authorizationChecker: authorizationChecker(this.authFactory),
currentUserChecker: currentUserChecker(this.authFactory),
controllers,
middlewares,
interceptors,
cors: true,
})
useExpressServer(appCopy, {
routePrefix: '/static',
controllers: staticControllers,
authorizationChecker: staticTokenAuthChecker,
})
I did not test, but I think that only adding cors
in the first useExpressServer
should solve it.
Anyway, it really feels like a bug, the framework should ignore if the user calls (by mistake) cors (or any other config boolean) twice.
Thanks for the answers!
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.
Description
Somehow, using CORS in my code, some routes are throwing Cannot set headers after they are sent to the client.
Minimal code-snippet showcasing the problem
Expected behavior
CORS should not get in the way here
Actual behavior
I'm really trying to figure out why (and when) cors is getting called here.
Any help is much appreciated!