代码之家  ›  专栏  ›  技术社区  ›  stkvtflw

Dialogflow api突然开始返回CORS错误

  •  1
  • stkvtflw  · 技术社区  · 6 年前

    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.
    

    我怎么解决这个问题?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Samuel Liew cicero lopes    6 年前

    解决此临时问题的一种方法是使用代理作为临时解决方案: 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

    推荐文章