如何解决当我在 Iframe 中加载应用程序并点击网络服务器 URL (Hapi JS) 时,请求对象中缺少 Cookie
我有一个使用 Hapi JS 实现的带有 Webserver 的应用程序,每当我使用浏览器选项卡打开应用程序时,我都能看到 cookie 被注入到请求标头中。 但是如果我通过 Iframe 在第三个应用程序中加载我的应用程序。标题中缺少 cookie。你能在这里请一些身体帮助吗。
Hapi 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。
有人可以帮忙吗
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。