remix-auth-socials - http 400 {“message”:“会话中缺少状态。”}在生产中,在本地主机上其工作
我正在尝试通过 https:/ 在我的第一个 remix.run js FW 上进行 Google 身份验证/www.npmjs.com/package/remix-auth-socials
在本地主机上,它工作得很好,但是在生产服务器上,它在重定向回调上崩溃:
- URL:[我正确的重定向 URI]
- 响应 http 代码: 400 错误请求
- 响应正文:{消息:“会话中缺少状态。”}
我的配置基于 npm 包:
// ~/services/session.server
export const sessionStorage = createCookieSessionStorage({
cookie: {
...
secure: true
},
});
...
我在固件代码中发现,如果无法从 remix sessionStorage 读取会话,则会崩溃并显示此消息。
有人知道是什么原因造成的吗?
I am trying to make work Google auth on my first remix.run js FW via https://www.npmjs.com/package/remix-auth-socials
On localhost, it works nicely, however on production server its crashing on redirect callback:
- URL: [my correct redirect URI]
- response http code: 400 Bad request
- response body: {message: "Missing state on session."}
My configuration is based on readme in npm package:
// ~/services/session.server
export const sessionStorage = createCookieSessionStorage({
cookie: {
...
secure: true
},
});
...
I found in FW code that its crashing with this message if it fails to read session from remix sessionStorage.
Does anybody knows what can cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
https://github.com/sergiodxa/remix-auth/discussions/ 156#discussioncomment-2536785
如果您来自以下国家之一,这是一个常见问题重新混合模板,其中 cookie 的 maxAge 设置为 0(对于实现“记住我”功能很有用)。然而,这意味着浏览器立即将 cookie 视为过时的。删除该属性或将其更新为更长的时间范围。我使用 maxAge: 60 * 60 * 24 * 30, // 30 天
https://github.com/sergiodxa/remix-auth/discussions/156#discussioncomment-2536785
This is a common issue if you're coming from one of the remix templates where the cookie's maxAge is set to 0 (useful for implementing a 'remember me' feature). However what this means is the browser immediately sees the cookie as stale. Either remove that property or update it to be a longer time frame. I use
maxAge: 60 * 60 * 24 * 30, // 30 days
https://developer.mozilla.org/ en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
就是这样,我没有在 https 上运行,所以解决方案是设置:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
This was it, i am not running on https, so solution was to set: