首页 > 解决方案 > 更改响应标题

问题描述

我有一个使用 create-react-app 创建的反应应用程序。我想将请求发送到另一个网址:

fetch('anotherUrl')
        .then(response => response.json())
        .then(res => console.log(res))

在那之后我有一个cors问题。如何将中间件设置为 null 这个错误?

标签: reactjsfetch

解决方案


您可以使用浏览器插件关闭 cors。在您完成应用程序的开发并将其上线后,cors 将不再是问题。只有当您在 localhost 中运行应用程序时才会出现问题。


推荐阅读