question

6666666 avatar image
0 Votes"
6666666 asked ZhiLv-MSFT commented

cors in nginx in signalr

in asp.net core signalr there is a cors can can not connect to the server when it is in nginx with javascript.

but it will be ok in debug in my computer.

is it something I have to config in nginx or centos?

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


dotnet-aspnet-core-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @6666666,

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

From this doc, you can find following information:

A CORS preflight request is used to determine whether the resource being requested is set to be shared across origins by the server. And The OPTIONS requests are always anonymous, server would not correctly respond to the preflight request if anonymous authentication were not enabled.

So, if your App(s) are hosted on IIS, you can try to install IIS CORS module and configure CORS for the app. And if your Apps are host on Linux, you should also enable CORS, please refer the following links:

How to add CORS (cross origin policy) to all domains in NGINX?

How to enable CORS in Nginx proxy server?

No 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST API

0 Votes 0 ·

0 Answers