Skip to content

Commit

Permalink
#174 [Backend] Setup Localhost Token And Cors
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Mar 4, 2023
1 parent 530d9eb commit b294b09
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
"[sql]": {
"editor.defaultFormatter": "adpyke.vscode-sql-formatter"
},
"cSpell.words": ["argothim", "MIDDLAWARE", "Middlawre", "mutilp"]
"cSpell.words": [
"argothim",
"Localstorage",
"MIDDLAWARE",
"Middlawre",
"mutilp"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const adminController = {
domain:
CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT
? req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0]
: '',
: CONSTANTS.HEADER_DOMAIN,
maxAge: CONSTANTS._1_MONTH,
});

Expand Down Expand Up @@ -260,7 +260,10 @@ const adminController = {
httpOnly: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
sameSite: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
secure: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
domain: req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0] || '',
domain:
CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT
? req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0]
: CONSTANTS.HEADER_DOMAIN,
maxAge: CONSTANTS._1_MONTH,
});

Expand Down
1 change: 1 addition & 0 deletions backend-manager-student/src/share/configs/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ module.exports = {
HEADER_HEADER_FORWARDED_HOST: 'x-forwarded-host',
HEADER_FORWARDED_FOR: 'x-forwarded-for',
HEADER_DEVICE: 'user-agent',
HEADER_DOMAIN: 'localhost',
/**
* @author Nguyễn Tiến Tài
* @created_at 05/02/2023
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const accessAdminMiddleware = async (req, res, next) => {

// Continue
return next();

} catch (error) {
return res.status(503).json({
status: 503,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ const userController = {
httpOnly: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
sameSite: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
secure: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
domain: req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0] || '',
domain: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT
? req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0]
: CONSTANTS.HEADER_DOMAIN,
maxAge: CONSTANTS._1_MONTH,
});

Expand Down Expand Up @@ -388,7 +390,9 @@ const userController = {
httpOnly: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
sameSite: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
secure: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT ? true : false,
domain: req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0] || '',
domain: CONFIGS.NODE_ENV === CONSTANTS.ENVIRONMENT_PRODUCT
? req.headers[CONSTANTS.HEADER_HEADER_FORWARDED_HOST]?.split(':')[0]
: CONSTANTS.HEADER_DOMAIN,
maxAge: CONSTANTS._1_MONTH,
});

Expand Down

0 comments on commit b294b09

Please sign in to comment.