为什么本地开发时请求后端接口总是跨域失败?
我在本地用 localhost:3000 启动了 React 项目,调用公司测试环境的 API(比如 https://api.test.com/user),浏览器一直报 CORS 错误。后端同事说他们已经加了 Access-Control-Allow-Origin: *,但还是不行,控制台显示:
Access to fetch at 'https://api.test.com/user' from origin 'http://localhost:3000' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response is 'https://www.test.com', which does not equal the supplied origin.
这说明后端其实没配成 *?还是我哪里理解错了?
暂无解答