GithubHelp home page GithubHelp logo

Web proxyUrl about google_place HOT 5 CLOSED

bazrafkan avatar bazrafkan commented on June 22, 2024 1
Web proxyUrl

from google_place.

Comments (5)

LucaDillenburg avatar LucaDillenburg commented on June 22, 2024

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.

log02 avatar log02 commented on June 22, 2024

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.

jardon-u avatar jardon-u commented on June 22, 2024

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.

LucaDillenburg avatar LucaDillenburg commented on June 22, 2024

@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.

log02 avatar log02 commented on June 22, 2024

thanks @LucaDillenburg I will test flutter_google_places_sdk

from google_place.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.