Bonjour,
J'aimeraia utiliser l'api TimeZone de google map sur un projet laravel 10 seulement je me heurte à un problème que je ne comprends pas avec la sécurité CORS.
En effet malgré la modification du fichier config/cors.php mon application ne fonctionne pas et je recois toujours la même erreur :
Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/timezone/json?location=42.6886591%2C2.8948332×tamp=663933600&key=API_KEY' from origin 'http://project.test' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.
Voici mon fichier cors.php :
'paths' => ['api/*', 'sanctum/csrf-cookie', '/'],
'allowed_methods' => ['*'],
'allowed_origins' => ['https://maps.googleapis.com/', 'project.test'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
Voici mon appel à l'api via axios :
axios.get('https://maps.googleapis.com/maps/api/timezone/json?location=42.6886591%2C2.8948332×tamp=663933600&key=API_KEY')
.then(function (response) {
// handle success
console.log('Response : ' + response);
})
.catch(function (error) {
// handle error
console.log('Error : ' + error);
})
.finally(function () {
// always executed
console.log('Finally');
});
Merci de m'aider s'il vous plait... en vrai je pète un plomb et ne comprends pas pourquoi ca ne veut pas fonctionner... Merci