Skip to content

Commit

Permalink
default content-type to html and json content type for json strings
Browse files Browse the repository at this point in the history
  • Loading branch information
suculent committed Nov 19, 2023
1 parent 0f55a8d commit 91fd77a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/router.auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ module.exports = function (app) {
console.log("logoutAction error", err);
}
});
} else {
console.log("[warning] logout attempt with undefined res.session!");
}
// Redirect to login page, must be on same CORS domain (public_url must be == public_url)...
res.redirect(app_config.public_url);
Expand Down
3 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ module.exports = function (app) {

app.all("/*", function (req, res, next) {

// Default content-type, may be overridden later by Util.responder and others
res.header("Content-Type", "text/html; charset=utf-8");

//
// JWT Key Authentication
//
Expand Down
1 change: 1 addition & 0 deletions lib/thinx/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module.exports = class Util {
} else if (typeOf(object) == "string") {
res.end(object);
} else {
if (typeof (res.header) === "function") res.header("Content-Type", "application/json; charset=utf-8");
res.end(JSON.stringify(object));
}
}
Expand Down

0 comments on commit 91fd77a

Please sign in to comment.