Cors issue when accessing google places API
Unanswered
Rock Dove posted this in #help-forum
Rock DoveOP
I've recently encountered a CORS issue while using the Google Maps API in my Next.js application. Everything was working fine until two days ago when this problem surfaced. I'm unsure what might have triggered it or how to resolve it.
I'm utilizing the Google Maps API to render maps within my Next.js application. However, when attempting to make requests to the API, I receive a CORS error. Here's the specific error message:
Im using this @react-google-maps/api react libraray
I'm utilizing the Google Maps API to render maps within my Next.js application. However, when attempting to make requests to the API, I receive a CORS error. Here's the specific error message:
Im using this @react-google-maps/api react libraray
6 Replies
dont fetch it client side @Rock Dove
fetch it from a server component, or else CORS issues will arise
@Rock Dove I've recently encountered a CORS issue while using the Google Maps API in my Next.js application. Everything was working fine until two days ago when this problem surfaced. I'm unsure what might have triggered it or how to resolve it.
I'm utilizing the Google Maps API to render maps within my Next.js application. However, when attempting to make requests to the API, I receive a CORS error. Here's the specific error message:
Im using this @react-google-maps/api react libraray
Hmm I also use that lib and can still render the map perfectly fine
https://github.com/joulev/website/blob/main/src/app/blogs/walking-on-singapore-mrt-lines/map.tsx
https://joulev.dev/blogs/walking-on-singapore-mrt-lines
https://github.com/joulev/website/blob/main/src/app/blogs/walking-on-singapore-mrt-lines/map.tsx
https://joulev.dev/blogs/walking-on-singapore-mrt-lines
@Arinji fetch it from a server component, or else CORS issues will arise
Rock DoveOP
how can we manage the client interactions on the map
@Arinji dont fetch it client side <@886074025938419723>
Rock DoveOP
why this cannot convert to server componenet
import { GoogleMap, Marker } from '@react-google-maps/api';
const containerStyle = {
width: '400px',
height: '400px',
};
const center = {
lat: -3.745,
lng: -38.523,
};
function MyComponent() {
return (
<GoogleMap mapContainerStyle={containerStyle} center={center} zoom={10}>
<>
<Marker position={{ lat: -3.745, lng: -38.523 }} />
</>
</GoogleMap>
);
}
export default MyComponent;