首页 > 解决方案 > 使用 ServiceStacks JsonServiceClient 时的 Cors 配置问题

问题描述

尝试使用 ServiceStack 的 JsonServiceClient 将数据发布到我的 API 时遇到问题。

我在控制台中收到以下错误消息

访问从源“ http://192.168.10.191:5000 ”获取“ https://192.168.10.191:5001/json/reply/CreateEquipment ”已被 CORS 策略阻止:访问不允许请求标头字段标头预检响应中的 -Control-Allow-Headers。

我已将 192.168.10.191:5000 添加到白名单。

我可以在网络选项卡中看到它尝试访问“ https://192.168.10.191:5001/json/reply/CreateEquipment ”,但是当我使用 fiddler 捕获流量时没有显示任何内容。

我附上了标题的图像。https://i.stack.imgur.com/hUfII.png

标签: servicestackserviceclient

解决方案


您在端口5001请求https资源,但您的原始白名单返回5000上的http资源,它们需要匹配。


推荐阅读