[英]How do make REST API call from React without passing through browser
I am making a REST API call from my React application and am running into the following problem:我正在从我的 React 应用程序调用 REST API 并遇到以下问题:
Access to XMLHttpRequest at '[API LOCATION]' from origin '[APPLICATION LOCATION]' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
How can I make the REST API call from my react client without the browser interfering?如何在没有浏览器干扰的情况下从我的反应客户端进行 REST API 调用? Where do I move the code?
我在哪里移动代码?
I have solved this by calling a Google Firebase function (see https://firebase.google.com/docs/functions ) from my React client.我已经通过从我的 React 客户端调用 Google Firebase function(参见https://firebase.google.com/docs/functions )解决了这个问题。 The Firebase function makes the REST API call and then returns the result back to the React client.
Firebase function 使 REST ZDB974238714CA8DE634A7CE1D08 调用返回到 React 客户端然后返回结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.