Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Amplify mock storage

I am trying to do a simple Storage.put into a mocked S3 bucket.

I have set everything up server-side already.

amplify add api
amplify add auth
amplify add storage

and I have pushed all of this to AWS and it works fine during testing.

When I run amplify mock storage the aws_config files are re-written as they should be to send all requests to the local mock storage and API.

However, inspecting the network requests shows that the mock S3 bucket it hosted on http://localhost:20005 (no SSL) and the request is sent to https://localhost:20005 (with SSL)

Even if I run my server with npm start or ($env:HTTPS="true") -and (npm start) it still does not successfuly run the Storage.put

The flag in the aws_config file is automatically set so that it should bypass this already:

"aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing": true,

The errors I receive are the following:

[ERROR] 42:36.732 axios-http-handler Error: Network Error
    at createError (createError.js:16)
    at XMLHttpRequest.handleError (xhr.js:81)

[WARN] 42:36.733 AWSS3Provider - error uploading Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:81)

Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:81)

Does anyone have any idea what the problem is here?

like image 787
HardBurn Avatar asked Jun 01 '26 07:06

HardBurn


1 Answers

Run your app without mocking

Look like there are bugs in running amplify mock for storage. What I did is as follows:-

  1. amplify push (Update your local changes to the cloud)
  2. Run react native, I am using expo, yarn start or expo start
  3. Make sure you're are not running the amplify mock.

Note that, when running your app, you're connecting directly to the cloud not with the mock data.

Conclusion

The bug might be with the amplify mock.

like image 147
Bernard Nongpoh Avatar answered Jun 04 '26 01:06

Bernard Nongpoh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!