如何在gae标准中实现nginx proxy_pass ?



我在GAE应用程序中使用firebase-ui-web进行身份验证。最近有一个令人讨厌的问题,Safari阻止第三方cookie,这破坏了登录过程。

最好的解决方案(在这里描述)似乎是实现nginx的反向代理配置。以下是详细信息:

# reverse proxy for signin-helpers for popup/redirect sign in.
location /__/auth {
proxy_pass https://<project>.firebaseapp.com;
}

是否有可能在GAE中完成同样的事情,我们无法添加nginx规则?我使用Python3/Flask,如果它的关系。

在谷歌上搜索了一下,我想到了这个:

@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

虽然我不确定来源是好的,所以欢迎反馈。

最新更新