node.js - 在 Azure 中使用 Cookie 进行身份验证 - React Web App
问题描述
我正在尝试将我的 React-Web-Application 从普通网络服务器迁移到 Azure Wep-App。该应用程序应该通过电子邮件+密码登录到我的后端。这行得通。后端发送带有身份验证令牌的响应,该令牌曾经保存在 cookie 中。令牌在响应中,但没有保存。它不会在浏览器、前端日志或后端日志上引发任何错误或警告。我不知道该怎么做,我不知道从哪里开始调试。也许我用错了整个 Azure 的东西?
这是后端的代码,它将邮件和密码与数据库进行比较,并在一切正常时发送令牌:
async (
req: ValidatedRequest<AuthenticateRequest>,
res: Response<AuthenticateResponse>,
next: NextFunction
): Promise<void> => {
try {
const mail = req.validData.mail;
const password = req.validData.password;
const user = await User.findByEmail(mail);
if (user !== null && await user.comparePassword(password)) {
const userRole = user.association;
// create the token
const token = issueToken(userRole, user._id);
res.cookie("cookieToken", token, {httpOnly: false});
res.send({ user: await transformUser(user), token, });
}
else {
throw new ErrorGeneric(errorCodes.ERROR_ACCOUNT_NOT_FOUND);
}
}
catch (error) {
next(error);
}
}
任何想法或帮助表示赞赏。:)
真诚的
解决方案
推荐阅读
- django - Django-taggit。如何为类别中的所有项目添加标签
- postgresql - 如何使我的扩展程序能够安装在任何方案中?
- node.js - 发送 Get 请求时出现 Enotfound 异常
- arrays - 二维数组的线性算法
- javascript - 需要帮助理解 DOM 元素和类中创建的对象之间的关系
- javascript - 允许设置/订阅单个项目的数组的 RxJs BehaviorSubject
- python - 无法在 selenium python IE 11 中使用 autoit 上传文件
- php - 表单等待第二次提交推送第一次提交
- ios - 无法实时获取 UserDefautls 更新的值
- mysql - 使用 @row_number/rank 的 mySQL 分页