[英]How to implement nginx proxy_pass in gae standard?
I'm using firebase-ui-web for authentication in my GAE app.我在我的 GAE 应用程序中使用 firebase-ui-web 进行身份验证。 There is an annoying issue recently where Safari is blocking 3rd party cookies and this breaks the login process.
最近有一个烦人的问题,Safari 正在阻止第三方 cookies,这会中断登录过程。
The best solution ( described here ) seems to be implement a reverse-proxy config with nginx. Here are the details:最好的解决方案( 此处描述)似乎是使用 nginx 实施反向代理配置。以下是详细信息:
# reverse proxy for signin-helpers for popup/redirect sign in.
location /__/auth {
proxy_pass https://<project>.firebaseapp.com;
}
Is it possible to accomplish the same thing in GAE where we are not able to add nginx rules?是否有可能在我们无法添加 nginx 规则的 GAE 中完成同样的事情? I'm using Python3/Flask if it matters.
如果重要的话,我正在使用 Python3/Flask。
With some Googling, I came up with this:通过一些谷歌搜索,我想出了这个:
@app.route('/<path:path>', methods=['GET', 'POST'])
def proxy(path):
url = f'https://www.example.com/{path}'
excluded_headers = ['content-encoding', 'content-length',
'transfer-encoding', 'connection']
if request.method == 'GET':
resp = requests.get(url)
elif request.method == 'POST':
resp = requests.post(url, data=request.form)
headers = [(name, value) for (name, value) in resp.raw.headers.items()
if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
Though I'm not confident that the sources are good so feedback is welcome.虽然我不确定来源是否良好,但欢迎提供反馈。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.