EDIT: a lenghty discussion in the comments lead to the insight that the external APi has no CORS implementation, thus the only two options would be: turn off cors (which is no option) or make a proxy implementation of the external API, as the results can be retrieved easily by curl.
I still stumble on the CORS issue: I am developing locally a laravel 10 app, which contains a vue component, which calls an external API on https://opendata.congreso.cl/...
So I browse to http://localhost:63350/dashboard where the vue component is embedded.
The external API is open, via browser I get the JSON result, but with the laravel app I get a CORS error (CORS Header missing)
My vue call is via fetch
const res = await fetch("https://opendata.congreso.cl/..);
and the config/cors.php is configured as follows:
return [
'paths' => ['dashboard/*','dashboard','api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*','https://opendata.congreso.cl/*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => ['*'],
'max_age' => 0,
'supports_credentials' => false,
];
the error is: Cross-Origin request blocked: The same source rule forbids the reading of external resources on ... the same source rule prohibits the reading of the external resource on ... (CORS-Header missing) status 200
strange thing is on the browser console I see the result, but it states that for scripts the CORS Missing Allow Origin
what do I miss? Where to look? I admit that I am still lost with these cors issues and I'm new to laravel 10