NiazMorshed2007 / shadcn-address-autocomplete

An address autocomplete component built with Google Places API and shadcn components.
https://shadcn-address-autocomplete.vercel.app/
179 stars 7 forks source link

Requests are returning error code 403 #1

Open monecchi opened 1 week ago

monecchi commented 1 week ago

Hi there! Thanks for the awesome component!

I've been trying to implement it on my project but I keep getting "Error: HTTP error! status: 403" while requesting Google Places API...

I've checked for my Google API Console and indeed I have Google Places API (New) enabled for my project and GOOGLE_PLACES_API_KEY in place under .env, so technically that should work.

I mean, it is a bit hard to debug it because responses from Nextjs api routes /app/api/address/autocomplete and /app/api/address/place are ok with status 200, but no results from Google Places API though.

Any ideas on how to circuvent that issue?

monecchi commented 1 week ago

I've managed to solve the issue by creating a new API KEY under Google API Console without any kind of restrictions.

It turns out I'm running it on localhost with https with along next dev --experimental-https, but even after whitelisting https://localhost:3000 under Google API Console > Credentials settings, requests were being blocked somehow. I'm not quite sure if Google denies requests from localhost, but it worked!

NiazMorshed2007 commented 1 week ago

Yep,, it's must to whitelist the domain where you'er requesting from. This maybe can also occur because of experimental https of nextjs, but it worked for me to just whitelist http://localhost:3000