I'm using firebase-ui-web for authentication in my GAE app. There is an annoying issue recently where Safari is blocking 3rd party cookies and this breaks the login process.
The best solution ( described here ) seems to be implement a reverse-proxy config with nginx. Here are the details:
# 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? I'm using Python3/Flask if it matters.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.