仅针对一个用户的随机 CORS 预检问题 [英] random CORS preflight problem only for one user

查看:21
本文介绍了仅针对一个用户的随机 CORS 预检问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 angular 8 开发的应用程序.它使用 httpClient 与后端通信并使用身份验证.

I have an application developed with angular 8. It uses httpClient to comunicate with the backend and uses autentication.

我有一个奇怪的问题,经过长时间的研究,我可以找到解决方案.

I have a weird problem I can find the solution after long research.

我的用户遍布世界各地,但只有其中一个失败.

I have users all over the world, and it only fails for one of them.

对于一个特定用户和(显然)随机,API 被拒绝,至少正如控制台中所说的那样,因为预检 CORS 问题:

For one particular user and (apparently) randomly, the APIs are rejected, and at least as it's said in the console, because of a preflight CORS issue:

Access to XMLHttpRequest 'myAPIip.com" from origin 'myip.com' 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

在控制台中,出现错误:

In the console, there is the error:

Error: Uncaught (in promise): EmptyError: no elements in sequence↵

以及所有这些堆栈跟踪.

and all this stack trace.

没有防火墙.

有人遇到过类似的情况吗?会发生什么?

Does anybody face similar situation? what can be happening?

推荐答案

FWIW,我们也面临着类似的问题.我们最终将其缩小到包含 unicode 字符的用户信息.例如,收到错误的用户的姓氏类似于:

FWIW, we were also facing a similar problem. We eventually narrowed it down to the user info containing a unicode character. For example, the user getting the error had a last name similar to:

  • 弗朗索瓦
  • 索里娜
  • 努涅斯

我们使用的 HTTP 代理无法处理此类 unicode 字符.希望这对未来的人有所帮助.

The HTTP proxy that we were using couldn't handle such unicode characters. Hope this helps someone in the future.

这篇关于仅针对一个用户的随机 CORS 预检问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆