I'm trying to make the expires_in property be dynamic for the response payload based on a custom property sent through saveToken() on the model.
I've enabled the continueMiddleware flag during the initialization of the middleware.
But when enabled, it's not possible to have any middleware be executed after OAuth calls next() since after calling that it still tries to call res.send through handleResponse.
Anything I try to execute in my OAuthExpiresInMiddleware will later then throw a unhandled rejection error with [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client.
This makes the
By doing some testing, I've noticed that adding a return to the code on line 157 makes it work.
-next();
+return next();
Without adding the return statement, any middleware added after the oauth.token() will only have the purpose of logging or something, but not actually returning data.
Hello!
I'm trying to make the
expires_in
property be dynamic for the response payload based on a custom property sent throughsaveToken()
on the model. I've enabled thecontinueMiddleware
flag during the initialization of the middleware. But when enabled, it's not possible to have any middleware be executed after OAuth callsnext()
since after calling that it still tries to callres.send
throughhandleResponse
.The current setup I have is:
Anything I try to execute in my
OAuthExpiresInMiddleware
will later then throw a unhandled rejection error with[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
. This makes thehttps://github.com/node-oauth/express-oauth-server/blob/ad70e7c33f20f53fa7293a8e96b226ecaf271dd7/index.js#L142-L165
By doing some testing, I've noticed that adding a
return
to the code on line 157 makes it work.Without adding the
return
statement, any middleware added after theoauth.token()
will only have the purpose of logging or something, but not actually returning data.Is proposed change possible?