node.js - 当我在 Iframe 中加载应用程序并点击网络服务器 URL(Hapi JS)时,请求对象中缺少 Cookie
问题描述
我有一个使用 Hapi JS 实现的 Web 服务器应用程序,每当我使用浏览器的选项卡打开应用程序时,我都能看到 cookie 被注入到请求标头中。但是如果我通过 iframe 在第三个应用程序中加载我的应用程序。标头中缺少 cookie。你能在这里请一些身体帮助吗?
哈皮JS代码
server.auth.strategy('session', 'cookie', {
password: 'longpassword-should-be-32-characters-for-pulse',
cookie: 'my-app-sid',
redirectTo: '/',
ttl: 86400000,
isSecure: false,
validateFunc: isAuth
});
和我的 API 调用,其中 req 标头中缺少 cookie
getBookDetails = () => {
return {
auth: {
strategy: 'session'
},
handler: {
proxy: {
mapUri: (request, callback) => {
let url = 'https://mydemoapp.com'
let tokenHeaders = { token: request.auth.credentials.token,
assetid: request.headers['assetid'],
asseturl:request.headers['asseturl'],
deviceid: deviceid,
appversion: request.headers['appversion'],
'user-agent': request.headers['user-agent'],
'accept-language': request.headers['accept-language']
};
url = url + '/book/' + request.params.bookId;
callback(null, url, tokenHeaders);
},
onResponse: (err, res, request, reply) => {
wreck.read(res, { json: true, gzip: true }, (err, payload) => {
reply(payload);
});
}
}
}
}
}
我怀疑因为我的应用程序是在第三方应用程序的 iframe 中加载的。并且在请求上面提到的网络服务器 URL getBookDetails() 时,它无法从父应用程序(第三方应用程序)读取 iframe 的 cookie。
有人可以帮忙吗
解决方案
推荐阅读
- javascript - 不要在angularjs的textarea中输入超过20个逗号分隔或换行符分隔的序列号和字母数字
- excel - 防止 PasteSpecial 命令自动粘贴值和合并列
- python - Python 3 中的打印功能不是添加而是附加?
- gcp-ai-platform-notebook - 我可以在 AI Platform 中创建 C2 实例 Notebook 吗?
- office-js - 我无法收到我在新邮件中添加的附件
- eclipse - Scala Script 在 REPL 中工作,但在 Scala IDE 上失败
- asp.net - DbContext.Query 不接受泛型类型 T,如何在 dot net core api 中进行泛型 DbContext 查询?
- apache-spark - 在 YARN 上使用 Spark 时 maxExecutors、num-executors 和 initialExecutors 之间的关系是什么?
- angular - 如何在角度中引入类似自定义生命周期事件的钩子
- jhipster - KeyCloak Docker compose:禁用表的覆盖