【问题标题】:Dialogflow api suddenly begun returning CORS errorDialogflow api突然开始返回CORS错误
【发布时间】:2018-10-15 10:35:51
【问题描述】:

Dialogflow 设置正确,并且可以正常运行大约一个月。今天它突然开始返回这个错误:

Failed to load https://api.dialogflow.com/v1/query?lang=en&query=hi&sessionId=bgknzzf1q: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4001' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

我该如何解决这个问题?

【问题讨论】:

标签: dialogflow-es


【解决方案1】:

解决此临时问题的一种方法是使用代理作为临时解决方案:https://www.npmjs.com/package/cors-anywhere

例子:

ApiAiConstants.DEFAULT_BASE_URL = 
    "https://cors-anywhere.herokuapp.com/https://api.api.ai/v1/";

缺点是授权标头和其他信息在途中传递并且可以被拦截。见https://github.com/dialogflow/dialogflow-javascript-client/issues/102

【讨论】:

  • 尝试删除函数和api网关并重新部署。这对我有帮助。我会尝试联系 AWS,因为这显然是一些可怕的错误
猜你喜欢
  • 2020-01-26
  • 2015-06-12
  • 2022-07-28
  • 2019-04-02
  • 1970-01-01
  • 2011-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多