Flask登录不能在同一域上的两个应用程序工作 [英] Flask-Login not working with two applications on same domain

查看:178
本文介绍了Flask登录不能在同一域上的两个应用程序工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在< domain> /< app_1> 上使用Flask登录近一年没有问题。最近,我使用相同的堆栈构建了第二个应用程序,并将其部署到< domain> /< app_2> 。现在,每当我登录任一个应用程序,它踢我从另一个。有什么原因吗?应用程序有不同的数据库和密钥,我想我可以有同一个域的两个cookie。



我不太熟悉cookie和不是肯定如何调试这个。

解决方案

我们很乐意提供标头或其他资讯,您需要配置Cookie 以使用单独的路径。

  app.config ['REMEMBER_COOKIE_PATH'] ='/ app_1'
pre>

I have been using Flask-Login on <domain>/<app_1> for almost a year without issue. Recently, I built a second application with the same stack and deployed it to <domain>/<app_2>. Now, whenever I log into either app, it kicks me out of the other. Is there a reason for this? The apps have different databases and secret keys, and I would have assumed I could have two cookies for the same domain.

I'm not too familiar with cookies and am not sure how to debug this. I'm happy to provide headers or other information if people can tell me what is relevant.

解决方案

You need to configure the cookies to use separate paths.

app.config['REMEMBER_COOKIE_PATH'] = '/app_1'

这篇关于Flask登录不能在同一域上的两个应用程序工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆