Why I get a CORS error:
Access to script at 'https://maps.googleapis.com/maps/api/js' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
When I try to import dynamically Google Maps API in my JavaScript:
await import('https://maps.googleapis.com/maps/api/js')
But not when I do it in my HTML:
<script defer src="https://maps.googleapis.com/maps/api/js"></script>
Any idea would be really appreciate it.
Note: if I import other URL libraries I don't have problems, ex: hammer.js cdn
async function init_map() {
await import('https://maps.googleapis.com/maps/api/js')
}
init_map()