ubuntu - 无法与 Rasa 服务器对话 - POST 时出现 CORS 错误
问题描述
我已经在 AWS Ubuntu 服务器上成功部署了 Rasa 服务器,它在终端中运行良好,但我无法通过 fetch() 从 POST 访问。
我运行这个命令:
rasa run --enable-api --cors *.*
它回应:
Starting Rasa server on http://localhost:5005
Rasa Sever is up and running.
它在浏览器(即 xxx.xxx.xxx:5005)中响应“来自 Rasa 的 Hello:2.8.3”,因此它已连接,但是当我尝试通过 fetch() POST 到 if 时,它给了我一个 CORS 错误:
const url = 'http://xxx.xxx.xxx.xxx:5005/model/parse';
fetch(url, { method: 'POST',
body: "{text:'Hello'}"})
.then(res => { console.log(res); res.json()})
.then(res => console.log(res))
解决方案
The url you added in your code is incorrect if you want a response.
const url = "HTTP://ip:5005/webhooks/rest/webhook";
fetch(url, { method: "POST",
body: "{sender: 'me', message: 'Hi'}"
})
If you still have any doubts feel free to ask.
推荐阅读
- web-scraping - 如何更改此公式以进行单元格引用
- database - 过滤地址列以仅显示城市
- reactjs - 图像出现在开发中,但在“REACT”中没有出现在生产中
- python - 对调试 Python 脚本进行更改会导致语法问题返回错误
- flutter - Flutter:如何为来自 Json 的动态数据(String、int、double)设置条件
- ios - 避免在水平紧凑环境下弹出框适应全屏
- sql - 我可以在 SQL Server 中使用派生列来执行 CASE 函数吗?
- python - 为什么我不能在 Jupyter Notebook 上导入 geopy.distance.vincenty()?我安装了geopy 2.0.0
- sql - 如果 DB2 不存在,则创建表/列 - 不使用 sp,仅手动查询
- pandas - 无法运行模块