the resource requested read present origin falta example error enable domain cross corb control cabecera allow ajax cors

ajax - resource - Error en Chrome: Content-Type no está permitido por Access-Control-Allow-Headers



falta la cabecera cors ''access-control-allow-origin'' jquery (6)

Configure CORS (solicitudes HTTP entre sitios) en el nodo. Para mí se parece a lo siguiente:

app.use(''/api'', function(req, res, next) { res.header(''Access-Control-Allow-Origin'', ''*''); res.header(''Access-Control-Allow-Headers'', ''X-Requested-With, Content-Type''); next(); });

Recibo este error en Chrome al intentar enviar una solicitud de Ajax:

Content-Type is not allowed by Access-Control-Allow-Headers

Todo funciona bien en Firefox.

¿Alguien puede ayudarme a resolver este problema?


Para mí con PHP, localy funciona incluso si configuro solo esta configuración de encabezado:

header(''Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'');


Resolví el problema de agregar a la configuración del host virtual del Servidor Web Apache las siguientes configuraciones

Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"


Solución para PHP:

header(''Access-Control-Allow-Origin: *''); header(''Access-Control-Allow-Methods: POST,GET,OPTIONS''); header(''Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'');

(Necesita enviar eso antes de cualquier otro contenido)


Tuve el mismo problema y lo resolví agregando el siguiente encabezado: Access-Control-Allow-Headers: content-type


para nginx

location / { proxy_pass http://localhost:59100; proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection ''upgrade''; proxy_set_header Host $host; # Simple requests if ($request_method ~* "(GET|POST)") { add_header "Access-Control-Allow-Origin" *; } # Preflighted requests if ($request_method = OPTIONS ) { add_header "Access-Control-Allow-Origin" *; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD"; add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept"; } # proxy_cache_bypass $http_upgrade; # add_header Access-Control-Allow-Origin *; # add_header Access-Control-Allow-Headers Content-Type; }

ver https://distinctplace.com/2017/04/17/nginx-access-control-allow-origin-cors/