You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi, I'm trying update to restify 11.0.0. But when I put the restify-jwt-community middleware I start to get on all request this error: Error [ERR_HTTP_HEADERS_SENT]: Cannot render headers after they are sent to the client
Even if the request is on the unless path.
If I comment server.use(rjwt({ secret: config.JWT_SECRET }).unless({path: ['/auth/token']})); the requests that don't use jwt token start to work fine.
UPDATE NOTE:
If remove the unless works fine.
As alternative to unless I did this:
server.use(rjwt({ secret: config.JWT_SECRET }), function (err, req, res, next) {
if (err) {
var path = [
'/path1',
'/path2',
];
var matches = path.filter(function (pattern) {
return new RegExp(pattern).test(req.url);
});
// If url match some path
if (matches.length > 0) {
return next();
}
return next(err);
}
return next();
});
Experiencing this with 2.0.0, using restify 11.1.0.
The reason for Error [ERR_HTTP_HEADERS_SENT]: Cannot render headers after they are sent to the client being seen is that each following request is being triggered twice.
I've implemented the workaround provided in the original comment, which works just fine.
Describe the bug
Hi, I'm trying update to restify 11.0.0. But when I put the restify-jwt-community middleware I start to get on all request this error:
Error [ERR_HTTP_HEADERS_SENT]: Cannot render headers after they are sent to the client
Even if the request is on the unless path.
If I comment
server.use(rjwt({ secret: config.JWT_SECRET }).unless({path: ['/auth/token']}));
the requests that don't use jwt token start to work fine.UPDATE NOTE:
If remove the unless works fine.
As alternative to unless I did this:
To Reproduce
Expected behavior
This code on restify 8.5.1 works fine.
System:
The text was updated successfully, but these errors were encountered: