Introduce env variable for webapp origin
This commit is contained in:
parent
a3ab275378
commit
7cc358dcb7
@ -72,8 +72,7 @@ async function resetPassword(req: express.Request, res: express.Response) {
|
||||
if(req.body.email != undefined) {
|
||||
// first stage: send reset token to email address
|
||||
|
||||
// this relies on the API being on the same hostname as the frontend
|
||||
const { origin } = new URL(req.protocol + '://' + req.headers.host);
|
||||
const origin = getWebAppOrigin();
|
||||
await passwordResetService.sendPasswordResetToken(req.body.email, origin);
|
||||
|
||||
return res.status(202).send({ success: true });
|
||||
@ -96,6 +95,14 @@ async function resetPassword(req: express.Request, res: express.Response) {
|
||||
}
|
||||
}
|
||||
|
||||
function getWebAppOrigin() : string {
|
||||
const origin = process.env.WEBAPP_ORIGIN;
|
||||
if (origin == undefined) {
|
||||
throw new Error('WEBAPP_ORIGIN not defined');
|
||||
}
|
||||
return origin;
|
||||
}
|
||||
|
||||
export default {
|
||||
createUser,
|
||||
getCurrentUser,
|
||||
|
@ -25,6 +25,7 @@ module.exports = {
|
||||
MAIL_SERVER_PORT: 587,
|
||||
MAIL_SERVER_USER: "mail_username",
|
||||
MAIL_SERVER_PASSWORD: "longrandompassword",
|
||||
WEBAPP_ORIGIN: "http://localhost:3000",
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -22,6 +22,7 @@ module.exports = {
|
||||
MAIL_SERVER_PORT: 587,
|
||||
MAIL_SERVER_USER: "mail_username",
|
||||
MAIL_SERVER_PASSWORD: "longrandompassword",
|
||||
WEBAPP_ORIGIN: "https://beta.colouring.london",
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user