createAmplifyGeocoder()
: "Access to fetch at 'https://places.geo.us-east-1.amazonaws.com/places/v0/indexes/mySearchIndex/search/suggestions' from origin 'https://XXXXXXX.replit.dev' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
#14109
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Geo
Amplify Version
v6
Amplify Categories
geo
Backend
Amplify Gen 2
Environment information
Describe the bug
When attempting to use the Amplify Geo service with
createAmplifyGeocoder()
to add a search input to a MapLibre map in an Amplify Gen2 project, the search request is blocked by CORS policy. The request to AWS Location Places API returns the error:Despite configuring Amplify with the appropriate search index and map resources, the CORS issue persists, indicating the request might be bypassing the backend and calling AWS directly.
I can successfully perform searches using
Geo.searchByText
andGeo.searchByCoordinates
directly, but integrating createAmplifyGeocoder() results in a CORS issue.Expected behavior
The search input should send requests to AWS Location Places through Amplify Geo, returning search results without CORS issues.
More specifically, the
createAmplifyGeocoder()
should work in the same way that I can call this successfully:Geo.searchByCoordinates
orGeo.searchByText
. Those return results correctly. But thecreateAmplifyGeocoder()
results in CORS errors.Reproduction steps
Create an Amplify Gen2 app using AWS Amplify.
Set up Amplify Geo with a map and search index by following the Amplify documentation for adding AWS Geo services.
Add a map to the app using createMap() and attach the geocoder control using:
Attempt to search using the map geocoder input.
Observe the CORS error in the console.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: