Comments (5)
As described by this issue the cors-anywhere.herokuapp.com proxy is being limited and basically should not be used as a long term solution.
You can use it by going to cors-anywhere.herokuapp.com in the browser and clicking in "Request temporary access to demo server". However, this will only solve the problem for a couple of minutes. After that, you would need to click again.
A free long term solution (still not production ready) would be to create your own heroku app with using the cors-anywhere repository. You can do that with the commands bellow:
# setup
git clone https://github.com/Rob--W/cors-anywhere.git
cd cors-anywhere
npm install
heroku create
# deploy
git push heroku master
ps: I didn't come up with the solution but for some reason I cannot find who did.
Also, this should be added to the README docs at the end. I can do that if approved.
from google_place.
Hi @LucaDillenburg. You say (not production ready) What do you think would be a good production solution ? My understanding is that google_place should implement web call with Google Maps JavaScript API V3.
from google_place.
For those discovering the issue. Google place api does not accept other websites to serve google content. Seems that this is only possible if you use the "Google Maps JavaScript API V3" (the official api that is web only). Unfortunately google_place (the flutter package) does not support this.
The solution for now is to deploy your own CORS proxy that will request the google place API and modify the response header to allow displaying the content anywhere.There are public CORS proxies but they limit the traffic and can be unsafe.
If you are on Heroku, check @LucaDillenburg answer in this thread.
If you are on GCP, just follow the instructions in https://github.com/taichunmin/gcf-cors-anywhere
Finally, depending on your CORS proxy api (if you use the GCP link above for example) you might need to use a patched version of google_place (the master branch does not allow some formats: egs my-proxy/cors?url=...). In this case add google_place like this to your puspec.yaml
google_place:
git:
url: https://github.com/Desync-o-tron/google_place
ref: feature-paths-in-proxyUrl
from google_place.
@log02 I believe a better solution would be to use the native SDKs instead of http requests in flutter web. I haven't tested it yet, but I believe it would remove the need of a cors-anywhere server. I found a package that claims to do just that: flutter_google_places_sdk.
However, if you intent to use this package, you could pay for either GCP or Heroku, as the free versions of these services probably don't provide enough enough instances, RAM and etc for production use.
from google_place.
thanks @LucaDillenburg I will test flutter_google_places_sdk
from google_place.
Related Issues (20)
- FormatException while passing proxy url HOT 2
- flutter web return null value HOT 8
- Optional timeout HOT 2
- Flutter Web - Can't google place autocomplete to work unless using proxy url. HOT 3
- get city name from results HOT 1
- no results when enabling api key restriction (android apps only) HOT 2
- [Questions] Photo Url When get Photo
- cors-anywhere proxy set-up HOT 1
- Locationbias error: Failed assertion: line 42 pos 14: 'point != null && circular != null && rectangular != null': is not true. HOT 1
- AutocompletePrediction.fromJson throws NoSuchMethodError: The method 'map' was called on null. HOT 1
- Not working in android. No error logs or warning. HOT 1
- Getting details from each types in the address_components
- Impossible to sort getNearBySearch() by distance using rankby parameter
- TimeoutException (Future not completed) HOT 1
- Return coordinates
- Place can't be choosen while typing in textfield.
- Android embedding v2.
- Limit Search Results?
- why is it discontinued HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google_place.