awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
919 stars 266 forks source link

AppSync upload of Complex Objects to S3 fails with CORS error on local mock server #639

Open sammartinez opened 3 years ago

sammartinez commented 3 years ago

Describe the bug When utilizing Complex Objects (as described here) to automatically upload files to S3, the upload will fail when utilizing amplify mock due to a CORS error. Based on the access errors I am getting, it looks like the client is trying to upload to the S3 bucket in AWS instead of utilizing the mock version on localhost. If I switch the implementation to manually uploading the file using Storage, the correct behaviour happens and the file is uploaded to the mock bucket hosted locally.

When not running amplify mock, the complex objects upload functionality works correctly with the cloud resources.

To Reproduce Implement a public file upload using complex objects as described in the docs. Run amplify mock. Attempt to upload a file.

Expected behavior Files automatically uploaded utilizing the complex objects API should use the local S3 mock server instead of the cloud environment bucket when running amplify mock.

Original Issue: https://github.com/aws-amplify/amplify-js/issues/7625