google-map-react icon indicating copy to clipboard operation
google-map-react copied to clipboard

No 'Access-Control-Allow-Origin' header is present on the requested resource

Open zainkhan10 opened this issue 4 years ago • 3 comments

I'm using this library for maps in my react application, and I'm adding search address functionality in my application and facing CORS error.

image

const handleApiLoaded = (map, maps) => {
    console.log('map, maps: ', map, maps);
    // use map and maps objects
    if (map && maps) {
        setApiReady(true);
        setMap(map);
        setMapApi(maps);
    }
};

{apiReady && <SearchBox map={map} mapApi={mapApi} addplace={addPlace} />}
<GoogleMapReact
    defaultZoom={4}
    bootstrapURLKeys={{
        key: 'API_KEY',
        region: 'US',
    }}
    defaultCenter={[41.25480000139866, -85.85206222945915]}
    yesIWantToUseGoogleMapApiInternals
    onGoogleApiLoaded={({ map, maps }) =>
        handleApiLoaded(map, maps)
    }
></GoogleMapReact>

I'm following this document to add search functionality

zainkhan10 avatar Feb 10 '22 21:02 zainkhan10

I'm facing the same issue. Can you please give the solution to this?

IMG 1---> Screenshot from 2022-07-04 14-46-34

IMG 2---> Screenshot from 2022-07-04 14-48-10

Thank You.

AadarshGhodasara avatar Jul 04 '22 09:07 AadarshGhodasara

@AadarshGhodasara that will cause these errors on localhost, but when your app is deployed over https, everything should be working.

zainkhan10 avatar Feb 24 '23 14:02 zainkhan10

i have the same issue trying to implement oauth2 from google. .from origin 'http://localhost:8101' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

wink15 avatar Feb 26 '24 12:02 wink15