【发布时间】:2019-10-18 09:12:31
【问题描述】:
postman post 请求返回来自 RASA NLU 的响应,但是当通过浏览器复制相同的内容时,post 请求从 POST 请求变为 OPTIONS 请求,并且没有来自 RASA NLU API 的响应。
【问题讨论】:
标签: python-3.x cors chatbot rasa-nlu rasa
postman post 请求返回来自 RASA NLU 的响应,但是当通过浏览器复制相同的内容时,post 请求从 POST 请求变为 OPTIONS 请求,并且没有来自 RASA NLU API 的响应。
【问题讨论】:
标签: python-3.x cors chatbot rasa-nlu rasa
要解决这个问题,你需要传递命令选项
--auth-token
您也可以将 None 作为身份验证令牌传递,这是默认选项,如下所示。
rasa run -m models --enable-api --log-file out.log --cors "*" --endpoints endpoints.yml --debug --auth-token None
您还需要通过将令牌添加为有效负载来更改您的 POST 请求。
例如:
$.ajax({
url: 'http://localhost:5005/webhooks/rest/webhook/',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({
message: msg,
sender: name,
token: 'None'
})
按 CTRL+SHIFT+R 重新启动 NLU 服务器并清除缓存的 JavaScript(如果存在)。现在 CORS 政策应该不是问题了。
【讨论】: