bonjour
J’ai ce code pour récupérer des infos sur un site :
let response = await fetch("https://unautre.site", {
method: "POST",
cache: "no-cache",
body: JSON.stringify(data)
});
J’ai cette erreur dans la console de mon navigateur :
Access to fetch at 'https://unautre.site' from origin 'https://mon.site' has been blocked by CORS policy: 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.
Mon serveur apache est configuré ainsi :
<VirtualHost *:80>
ServerName mon.site
DocumentRoot /var/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type"
RewriteEngine On
</VirtualHost>
Pourquoi CORS policy me bloque ?
+0
-0