Express compatible request object
Is there an Express compatible
request
object available from a server route? I am trying to integrate samlify
and it needs to parse the request but it seems the nitro
request object is incompatible.10 Replies
you can try using
event.node.req
but it'll go away in the next major
or toNodeMiddleware
with samlifyyea I'm using
event.node.req
right now. Is toNodeMiddleware
avaiable in v3.12 with v4 compatibilityVersion set?
const { extract } = await serviceProvider.parseLoginResponse(identityProvider, 'post', event.node.req)
aaah maybe this will work: https://nuxt.com/docs/guide/directory-structure/server#legacy-handler-or-middlewareYes it should be
Ah sorry yes
From not to 👀
Ok so it looks like the error I'm getting is because request.body is undefined
Did you read the body beforehand?
no I haven't
does
fromNodeMiddleware
parse the body or do I need to install the express bodyParser
somehow?If you would need it with samlify maybe
(Never used that lib)
How did you try using it with fromNodeMiddleware?
Same code as above:
const { extract } = await serviceProvider.parseLoginResponse(identityProvider, 'post', request)
its expecting request.body
to existCan you show the whole code?
hmm i bet its the async
nope =\
I even installed bodyParser as a server middleware but that just gives me an empty object
{}
instead of undefined
export default fromNodeMiddleware(bodyParser.text())
Weird, even using a normal event handler, the body is { '{}': '' }
ok I don't know why it's looking at the body... the damn thing is urlencoded!
aha! export default fromNodeMiddleware(bodyParser.urlencoded({ extended: false }))
Now to get that body parser only on that route