Javascript Python在POST中失败,但在GET中通过

Javascript Python在POST中失败,但在GET中通过,javascript,python,nginx,flask,cors,Javascript,Python,Nginx,Flask,Cors,我已经使用python flask创建了一个后端api,并托管在gcp计算引擎上 当我尝试使用网站访问api并在java脚本中执行fetch()调用时,我得到了CORS错误 Access to fetch at 'https://{ip}/api' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the

我已经使用python flask创建了一个后端api,并托管在gcp计算引擎上

当我尝试使用网站访问api并在java脚本中执行
fetch()
调用时,我得到了CORS错误

Access to fetch at 'https://{ip}/api' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
当我执行
GET
调用时,该调用正在工作,但我的
POST
调用不工作,并给出上述错误

下面是失败的POST呼叫

@app.route('/api/v1/xxx', methods=['POST'])
@cross_origin(origin='localhost',headers=['Content- Type'])
def upload_file():
    #some code
        return "successfully"
下面是正在工作的get呼叫

@app.route('/api/v1/xxx', methods=['GET'])
@cross_origin(origin='localhost',headers=['Content- Type'])
def signUpCheck():
    #some code
    return jsonify(fun())

我找到了解决方案的答案, 所以发生的事情是,我通过nginx路由所有呼叫,因此在服务器端,我只收到选项呼叫,其他什么都没有。 当我试图通过postman而不是javascript调用API时,我收到了文件大小异常。我必须在我的nginx文件中添加以下行才能解决这个问题

client_max_body_size 100M;

一般来说,如果服务器端出现错误,您将收到cors错误,因此请务必通过postman尝试api调用

在该python/flask环境的日志中,服务器在发送对该POST请求的响应之前,会记录哪些消息?