CORS Error with JS google maps api in .net core app

I am trying to render Google map using JS in .net core 5 view as follows:

<div id="map"></div>

@section Scripts{

<script src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap&libraries=&v=weekly" async></script>
<script>


    function initMap() {
        // The location of Uluru
        const uluru = { lat: -25.344, lng: 131.036 };
        // The map, centered at Uluru
        const map = new google.maps.Map(document.getElementById("map"), {
            zoom: 4,
            center: uluru,
        });
        // The marker, positioned at Uluru
        const marker = new google.maps.Marker({
            position: uluru,
            map: map,
        });
    }

</script>

}

I also enable CORS in Setup.cs

 services.AddCors();

and

app.UseCors(options => options.WithOrigins("The Published website URL").AllowAnyMethod());

But in Edge console I got the following error:

enter image description here