Description
I have a function that takes a bearer token in its authorization header which isn't a JWT.
When deployed to Netlify, that works fine, everything's great.
When run locally with netlify-lambda serve
, any bearer tokens present are always parsed as JWTs, which fails, so the function returns 500 and never runs: https://github.com/netlify/netlify-lambda/blob/master/lib/serve.js#L83-L91.
I think the logic there should handle this case. If there's a bearer token that parses as a JWT, emulate assume it's a Netlify JWT and emulate Netlify identity. However if token parsing fails, continue the request as an unauthenticated request, and so potentially allow the function to use/validate the authorization token itself.
For now as far as I can tell there's no nice way to work around this, so my function works perfectly when deployed but is impossible to test locally, so this is a fairly major problem for this case.