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
Returning this.statusCode(401) from controller extending BaseHttpController should return 401 status to client.
Current Behavior
Throws:
TypeError: Cannot read property 'headers' of undefined
Possible Solution
Not entirely sure. The code seems to check whether message.content is defined in server.ts, but the compiled code just calls it directly.
// Raw copy from node_modules/inversify-express-utils/lib/server.js
InversifyExpressServer.prototype.handleHttpResponseMessage = function (message, res) {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
this.copyHeadersTo(message.headers, res);
this.copyHeadersTo(message.content.headers, res); // Here is the problem
if (!(message.content !== undefined)) return [3 /*break*/, 2];
_b = (_a = res.status(message.statusCode)).send;
return [4 /*yield*/, message.content.readAsStringAsync()];
case 1:
_b.apply(_a, [_c.sent()]);
return [3 /*break*/, 3];
case 2:
res.sendStatus(message.statusCode);
_c.label = 3;
case 3: return [2 /*return*/];
}
});
});
};
Steps to Reproduce (for bugs)
Set up a basic project and create a controller
Create async handler for an httpGet path
return this.statusCode(401)
Context
I'm trying to return 401 errors when users are not authenticated. Preferably I'd like to also return a message, but just the error code is sufficient for now.
Your Environment
Windows 10x64
Node 10
inversify-express-utils version 6.1.0
Stack trace
TypeError: Cannot read property 'headers' of undefined
at InversifyExpressServer. (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:201:60)
at step (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:32:23)
at Object.next (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:13:53)
at C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:7:71
at new Promise ()
at __awaiter (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:3:12)
at InversifyExpressServer.handleHttpResponseMessage (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:195:16)
at InversifyExpressServer. (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:242:51)
at step (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:32:23)
at Object.next (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:13:53)
The text was updated successfully, but these errors were encountered:
rudfoss
changed the title
inversify-express-middleware returning this.statusCode(401) results in
inversify-express-middleware throws when returning this.statusCode(401)
Aug 27, 2018
Expected Behavior
Returning this.statusCode(401) from controller extending BaseHttpController should return 401 status to client.
Current Behavior
Throws:
Possible Solution
Not entirely sure. The code seems to check whether
message.content
is defined inserver.ts
, but the compiled code just calls it directly.Steps to Reproduce (for bugs)
Context
I'm trying to return 401 errors when users are not authenticated. Preferably I'd like to also return a message, but just the error code is sufficient for now.
Your Environment
Windows 10x64
Node 10
inversify-express-utils version 6.1.0
Stack trace
TypeError: Cannot read property 'headers' of undefined
at InversifyExpressServer. (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:201:60)
at step (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:32:23)
at Object.next (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:13:53)
at C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:7:71
at new Promise ()
at __awaiter (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:3:12)
at InversifyExpressServer.handleHttpResponseMessage (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:195:16)
at InversifyExpressServer. (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:242:51)
at step (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:32:23)
at Object.next (C:\Users\Thomas Rudfoss\Projects\demo-node-server\node_modules\inversify-express-utils\lib\server.js:13:53)
The text was updated successfully, but these errors were encountered: