Open orangegrove1955 opened 2 years ago
Hi @orangegrove1955 Thanks for raising this issue. I was able to reproduce this and it seems when stopping the mock endpoint, this line that is added by mocking remains in the aws-exports
file.
"aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing": true
A temporary workaround may be to manually remove it in order to go back to using the deployed S3 bucket.
Because the mock functionality belongs to the CLI, I'm going to transfer this issue over to the CLI repo to be looked into further.
Hey @orangegrove1955 just to echo what @chrisbonifacio said, thanks for raising 🙂. I've also confirmed I am seeing the aws-exports line get added when we start mock, and when we stop mock the setting remains which can cause confusion. Ideally this setting will be set to false or removed all together when stopping the mock functionality. Marking as a bug 🙂
Hey, thanks for the fix! It does seem to have fixed the location the PUT call is being made to, it's aimed at the bucket now. It appears I'm getting a CORS issue here now though, any suggestions on how to resolve them?
Thanks in advance!
Hey, sorry, further update after more digging. Turns out the bucket that was being used in aws-exports
as well as amplify/backend/storage/myStorage/parameters.json
didn't match up with the one in my AWS console
Specifically, the bucket that exists in my AWS console is myStorageBucket203122
but the name in both the files is just myStorageBucket
(this part of the name is changed, but not the numbers, let me know if you need it specifically)
I don't recall any point where I renamed the bucket or changed these files, so not sure how this has happened, but wanted to put it down here for your information, and for anyone else who might encounter this issue
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API, Storage
Amplify Categories
No response
Environment information
Describe the bug
Using Storage.put I am receiving an ERR_CONNECTION_REFUSED response on the Amplify hosted version of my React app. I am also seeing this same issue in my local version of the React app when
amplify mock
is not runningThe link address in the console errors is
http://localhost:20005/XXXXXX-dev/public/XXXXXX?x-id=PutObject
(XXXXXXX used in place of specific details, let me know if you need them) which seems like the online hosted version is trying to use the locally mocked S3 bucket details instead of the actual bucket onlineWhen using Storage.get, it also appears to use the localhost value for the link address
I have seen issues aws-amplify/amplify-js#5608 aws-amplify/amplify-js#5572 aws-amplify/amplify-js#5621 and tried the suggested method of removing the
package-lock.json
file andnode_modules/
folder, but this has not resolved the issueExpected behavior
I would expect the Storage.put and Storage.get calls to use the deployed S3 bucket not localhost, and successfully put files into the S3 bucket
Reproduction steps
Auth and guest users
for bucket permissions in CLIamplify push
amplify mock
npm run start
amplify mock
- should workamplify mock
Code Snippet
Log output
aws-exports.js
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