GAE / GCP Flex Env​​ironment Flask应用程序不断将HTTPS重定向到HTTP

时间:2019-06-15 12:49:03

标签: google-app-engine redirect flask https google-cloud-platform

我知道在这个GAE / Flask问题上已经有大量的已回答的SO问题,但是没有人解释我正在观察的内容。当我的前端通过https点击Flask应用程序时,它会继续重定向到http,由于HTTP/HTTPS混合内容规则而失败。

这是Chrome开发工具的输出:

Mixed Content: The page at 'https://storage.googleapis.com/staging-fubar/index.html#/?_k=flnjq1' was loaded over HTTPS, but requested an insecure resource 'http://staging-goomba-dot-bingbong.appspot.com/autocomplete/thingy/5'. This request has been blocked; the content must be served over HTTPS.

这是我执行复制->在开发工具中复制为cURL并在终端中执行失败的请求时的输出:

curl 'https://staging-goomba-dot-bingbong.appspot.com/autocomplete/target/thingy/5' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36' -H 'Referer: https://storage.googleapis.com/staging-fubar/index.html' -H 'Origin: https://storage.googleapis.com' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjU0OGYzZjk4N2IxNzMxOWZlZDhjZDc2ODNmNTIyNWEyOTY0YzY5OWQiLCJ0eXAiOiJKV1QifQ.eyJNSkYiOnRydWUsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9tamYtZGVsaXZlcmFibGUiLCJhdWQiOiJtamYtZGVsaXZlcmFibGUiLCJhdXRoX3RpbWUiOjE1NjA1NDY3NzYsInVzZXJfaWQiOiJwZXRlckBvY2NhbXpyYXpvci5jb20iLCJzdWIiOiJwZXRlckBvY2NhbXpyYXpvci5jb20iLCJpYXQiOjE1NjA1NDY3NzYsImV4cCI6MTU2MDU1MDM3NiwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6e30sInNpZ25faW5fcHJvdmlkZXIiOiJjdXN0b20ifX0.E-pGxO_vrL1255Sm7C1YOL8T0gZr0H3fIfanNEewmJxQOFzw8HWZMhyc7dgnaITQsbv6HHuI7I3rvPqnpPS161BtzB8z_reYeScIZBtn6v3gJghs6C2__Hmuaht-PHVsMVqw98lSLRwtZ0-5xVf4bj2R9mzrvRDGxYjvypnL0SBU7NdUrVUGgJvV_E13f-IneSJ27XFcuVcH_jgpYU-HIOOD6mvbYGr79xCrQDMS1KDlO2o5Ux5uR0-7K-n6B5j63l9icwGCWt1BjLcrRigCDQdmrmuUfLHWXnvq1ZAQxCQ7lrIvtwAHCCEQkEjalzrH73GS-iggEoZjRU2NE4nlKw' --compressed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a     href="http://staging-goomba-dot-bingbong.appspot.com/autocomplete/thingy/5">http://staging-goomba-dot-bingbong.appspot.com/autocomplete/thingy/5</a>.  If not click the link.%

这是到达的路线/终点:

@app.route('/autocomplete/<string:term>',
           defaults={"search_type": 'target', "type_str": None, "limit_count": 10},
           strict_slashes=False)
@app.route('/autocomplete/<string:term>/<int:limit_count>',
           defaults={"search_type": 'target', "type_str": None},
           strict_slashes=False)
@app.route('/autocomplete/<string:search_type>/<string:term>',
           defaults={"type_str": None, "limit_count": 10},
           strict_slashes=False)
@app.route('/autocomplete/<string:search_type>/<string:term>/<int:limit_count>',
           defaults={"type_str": None},
           strict_slashes=False)
@login_required
def autocomplete(search_type, term, type_str, limit_count):
...

我检查了路由的功能是否没有print anything。在localhost上运行很好,可能是因为SSL没有起作用。

到目前为止,我一直无济于事:

  • http的{​​{1}}部分中删除openapi.yaml
  • adding SSLify
  • 重新部署以防一次性部署问题

对于引起此问题的原因或如何缩小范围的建议将不胜感激!

Pete

0 个答案:

没有答案