Der Header "Access-Control-Allow-Origin" enthält mehrere Werte. Ich habe jedoch nur einen Wert im Header definiert?
Posted: 03 Jun 2025, 15:52
Der folgende Fehler wirft mich bei einer Anfrage aus: < /p>
Access to XMLHttpRequest at 'My Server URL' from origin 'Server Name' has been
blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple
values 'Server Name, *', but only one is allowed.
< /code>
In meiner Datei webapiconfig.cs habe ich die CORS -Richtlinie wie folgt definiert: < /p>
var cors = new EnableCorsAttribute("MyServerName", "Content-Type", "GET,PUT,POST,DELETE");
config.EnableCors(cors);
< /code>
Ich habe nur einen Wert myServername < /em> definiert, aber der geworfene Fehler definiert ihn als 'Servername, *' < /code> < /p>
update: < /strong> < /p>
Access to XMLHttpRequest at 'My Server URL' from origin 'Server Name' has been
blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in
the response must not be the wildcard '*' when the request's credentials mode is
'include'. The credentials mode of requests initiated by the XMLHttpRequest is
controlled by the withCredentials attribute.
< /code>
Ich habe keine CORs in meiner Web.config-Datei definiert.>
Access to XMLHttpRequest at 'My Server URL' from origin 'Server Name' has been
blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple
values 'Server Name, *', but only one is allowed.
< /code>
In meiner Datei webapiconfig.cs habe ich die CORS -Richtlinie wie folgt definiert: < /p>
var cors = new EnableCorsAttribute("MyServerName", "Content-Type", "GET,PUT,POST,DELETE");
config.EnableCors(cors);
< /code>
Ich habe nur einen Wert myServername < /em> definiert, aber der geworfene Fehler definiert ihn als 'Servername, *' < /code> < /p>
update: < /strong> < /p>
Access to XMLHttpRequest at 'My Server URL' from origin 'Server Name' has been
blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in
the response must not be the wildcard '*' when the request's credentials mode is
'include'. The credentials mode of requests initiated by the XMLHttpRequest is
controlled by the withCredentials attribute.
< /code>
Ich habe keine CORs in meiner Web.config-Datei definiert.>