You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo Web版React Native应用CORS错误求助

Expo Web 跨域(CORS)问题求助

我尝试使用Expo Web功能在浏览器中运行React Native Expo应用,但遇到了跨域问题。我已经在前后端配置了如下CORS响应头:

headers: {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "Origin, Content-Type",
  "Content-Type": "application/json",
},

但浏览器仍报错:

Access to XMLHttpRequest at 'https://21c9-197-26-42-128.eu.ngrok.io/server/...' from origin 'http://localhost:19006' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.

注:我清楚移动端应用无需配置CORS,但我的目标是让应用在Web端运行,且仅Expo Web版本出现此问题。

请求头截图:
请求头截图

响应头截图:
响应头截图

请问有人解决过这个问题吗?

内容的提问来源于stack exchange,提问作者ElVincitore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 01:46:18