Inconsistent CORS errors in React UI calls to net 6 web API

A React app is calling my net6 API. Things have been working fine for months with no CORS problems.

Starting this week, I started seeing the React client unable to call the API consistently.
Things work fine other environments. But in a STG environment requests are blocked, but inconsistently. That is, some requests to a single controller get through while others do not. In addition, reloading the UI page results in a different set of endpoint calls that fail.

I have not been able to identify the cause. I don’t know if there is a change in React client code that could account for this. I haven’t found anything unusual about the server where the API is hosted in IIS. I am not aware of any new security in that environment. Any suggestions as to what could explain the inconsistent CORS errors?

I believe I have CORS access correctly enabled in the API (this has worked for 8 months in all environments with no CORS issues):

        private readonly string _policyName = "CorsPolicy";

            services.AddCors(opts => {
                opts.AddPolicy(_policyName, builder => {
                    builder.AllowAnyOrigin().
                            AllowAnyMethod().
                            AllowAnyHeader();
                });
            });

            app.UseRouting();
            app.UseCors(_policyName);

The fact that some requests get through seems to indicate CORS is configured appropriately in the API app.
The inconsistency must be a clue as to what is going on and how to resolve it.

From the Chrome browser dev tools Console:

Access to XMLHttpRequest at 'https://some-domain.com/MyApp/SomeController/SomeEndpoint' from origin 'https://webapp-client.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
 
GET https://some-domain.com/MyApp/SomeController/SomeEndpoint net::ERR_FAILED 500 (Internal Server Error)

On calls that fail, the OPTIONS call returns:

500 Internal Server Error

On calls that succeed, the OPTIONS call returns as expected:

Access-Control-Allow-Headers:  authorization
Access-Control-Allow-Methods:  GET
Access-Control-Allow-Origin:   *

Calling the same endpoint 20 seconds later, it may succeed, or it may fail. It is inconsistent.

Any suggestions on how to resolve this issue?

I have tried adding [EnableCors(“CorsPolicy”)] decorations to endpoint Action methods. No effect.
I have tried to identify why calls to some endpoints succeed while others fail. They are all implemented the same way.
I have asked the UI dev if there was a change from his end. No change he is aware of.
I asked the architect guy if there is a new security aspent in the affected environment. None he is aware of.
I have done many google searches similar to “Inconsistent CORS errors” but have not found anything that looks like my situation.

I would expect that a React client calls to an API endpoint would consistently fail or consistently succeed, all other things being unchanged. In the past, CORS errors I have seen are consistent and can usually be addressed by an appropriate change. At this point, I suspect a network security issue, but I have no way to verify that.

Any suggestions are appreciated.

New contributor

user25671135 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật