Open Sleavely opened 3 years ago
Can confirm this is still occurring as of January 2024 / 1.0.3. A fix would be fantastic. Explicitly targeting /
in addition to the global call works, e.g.:
api.use('/', apiCommon.corsMiddleware);
api.use(apiCommon.corsMiddleware);
When using a base path, the
/
route doesn't seem to run middleware properly.I wrote a failing test case using CORS as an example to illustrate:
The route itself runs and returns
{ status: 'ok' }
but the CORS headers are missing. If the registered route is changed it works as expected:Interestingly, the error middleware runs fine regardless of the route. If you remove the route
/
and change the event path to something like'/base-path'
you'll get a 404 (or 405, don't recall) but the CORS headers will be there