-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flutter Web AutocompletePlace XMLHttpRequest Error #14
Comments
Hi @Bylinkk I will update it as soon as possible. Could you please elaborate on your problem? |
Hey @Bylinkk , this is caused by CORS.
|
Thanks for your feedback. I really don't know how to solve this problem! |
It seems to be only a problem with localhost, after the deployment CORS problems are automatically fixed. You can try it once 🤔 I'm not sure. |
Hi, I just did the test in production but the CORS problem is still present. You can check for yourself on the following links: The javascript console displays the CORS error:
Thank you for your help |
hi @rvndsngwn I am experiencing the same issue, tried already many things like adding the headers Also tried some CORS proxies, but those are just temporary solutions. Still getting "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.". Tried to make server side changes, nothing helps. I don't know what to do anymore. My app works on mobile but not on web. Sadly |
https://pub.dev/packages/flutter_cors Guys you can use this package only for local testing. |
Hi @rvndsngwn |
I have worked on it, the same issue was with me, so I used OpenStreetMap instead and got the desired result. |
This problem has been presented to me in several opportunities when I try to use google apis (youtube, address, places, etc) from flutter web, the way in which I have solved it is defining functions in my services api rest that make of pass buckets to make the requests to google and to return the answers to my application, in the case of the widget PlacesAutocomplete has the property placesBaseUrl, there you define your route in the backend where you consult the services of google, in my case it is: https://my.api.server.com/utils. But the routes that I define in my server to consume the google services were: https://my.api.server.com/utils/place/autocomplete/json?input=address exampl for this service I use the function: async getPlacesByInput(input: string): Promise { https://my.api.server.com/utils/place/details/json?placeid=placeIdExample and for this service I use the function: async getPlaceDetails(placeId: string, returnAll: Boolean): Promise {
I hope my explanation helps you. Happy code!!!! |
How to fix this CORS issue, Any update ? |
Any updates on this?? As for me it works fine on any pc's web browser but does not work from any mobile browser. |
For Geocoding You need to build a proxy on your server in order to be able to get your correct response. The actual service is always returning CORS issues so building your own make you control the access control. On Flutter
I built that quick NodeJS firebase function that mimic the same URL of geocoding (in that case) :
Then it works fine. That still a lot of work for something that could already work.... |
To resolve the CORS issue, easiest way is use Thank you, @bertrandgelinas , for providing the best guidance on how to use firebase functions. Firebase: https://firebase.google.com/docs/functions |
The function of @bertrandgelinas concerns geocoding. For place search use this instead: On flutter On firebase function
However, the search works well but there is an error when selecting the chosen address: #0 packages/map_location_picker/src/autocomplete_view.dart 504:7 _getDetailsByPlaceId I wrote my message too quickly |
@AndresPinto2203 Where do you call this function: getPlaceDetails ? |
Hi,
After reading multiple XMLHttpRequest errors and CORS security issues, I can't work the autocomplete search on Chrome. Can we just remove this function to give the user the possibility to only use the current location button? Or can you help me to make this function work easily ?
Thank you in advance for your return.
The text was updated successfully, but these errors were encountered: