【问题标题】:Flask API, browser requests stopped working, no log the request was receivedFlask API,浏览器请求停止工作,没有收到请求的日志
【发布时间】:2021-10-18 12:51:01
【问题描述】:

我有一个非常简单的烧瓶应用程序,它已经工作了多年,但上周来自构建应用程序的请求返回 500,而从 Flask 方面,我什至看不到请求。我没有看到 OPTIONS 请求。

以下几行以前可以让 CORS 满意。

@app.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', '*')
    response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization,Auth-Token')
    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
    return response

我在几个浏览器中尝试过,但都未能成功发出任何请求。由于服务器甚至不确认已发出请求,因此我不确定在哪里进行故障排除。当我使用 Postman 发出请求时,我确实确认该应用程序按预期返回数据,并确认如果我在本地使用该应用程序(我的计算机上的 gulp 服务)请求成功。我必须相信它的 CORS,但是我必须添加/做什么才能让浏览器满意?谢谢。

【问题讨论】:

    标签: flask


    【解决方案1】:

    我的问题的解决方案是chrome开始“限制网站与本地网络上的设备通信的能力”

    Communicating from Chrome 94+ with LAN devices that do not support HTTPS from a web app

    【讨论】:

      猜你喜欢
      • 2016-03-18
      • 2013-02-26
      • 2016-01-31
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-10
      • 1970-01-01
      相关资源
      最近更新 更多