From 793597085ba970ece7f38e79ed67f99e1e210936 Mon Sep 17 00:00:00 2001 From: Tian Yunhao Date: Thu, 18 Apr 2019 10:03:24 +0800 Subject: [PATCH] Fix protocol in Email. --- modules/api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/api.js b/modules/api.js index 7fe2da4..fad6caf 100644 --- a/modules/api.js +++ b/modules/api.js @@ -42,7 +42,8 @@ app.post('/api/forget', async (req, res) => { expiresIn: '12h' }); - const vurl = req.protocol + '://' + req.get('host') + syzoj.utils.makeUrl(['api', 'forget_confirm'], { token: token }); + const currentProto = req.get("X-Forwarded-Proto") || req.protocol; + const vurl = currentProto + '://' + req.get('host') + syzoj.utils.makeUrl(['api', 'forget_confirm'], { token: token }); try { await Email.send(user.email, `${user.username} 的 ${syzoj.config.title} 密码重置邮件`, @@ -92,7 +93,8 @@ app.post('/api/sign_up', async (req, res) => { expiresIn: '2d' }); - const vurl = req.protocol + '://' + req.get('host') + syzoj.utils.makeUrl(['api', 'sign_up_confirm'], { token: token }); + const currentProto = req.get("X-Forwarded-Proto") || req.protocol; + const vurl = currentProto + '://' + req.get('host') + syzoj.utils.makeUrl(['api', 'sign_up_confirm'], { token: token }); try { await Email.send(req.body.email, `${req.body.username} 的 ${syzoj.config.title} 注册验证邮件`,