Skip to content
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

S3: header errors when uploading file #5376

Closed
lambda0xff opened this issue Apr 12, 2020 · 13 comments · Fixed by #5508
Closed

S3: header errors when uploading file #5376

lambda0xff opened this issue Apr 12, 2020 · 13 comments · Fixed by #5508
Assignees
Labels
Storage Related to Storage components/category to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@lambda0xff
Copy link

lambda0xff commented Apr 12, 2020

Describe the bug
When uploading a file to S3, I get error/warning messages from the browser:
Refused to set unsafe header "content-length"
Refused to set unsafe header "host"
in chrome

Attempt to set a forbidden header was denied: content-length
Attempt to set a forbidden header was denied: host
if firefox

To Reproduce
Using the aws-amplify library: storageClass.put(key, blob, { level, contentType: type, cacheControl: 'max-age=31536000'}))
and CORS settings in S3:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
    <ExposeHeader>x-amz-request-id</ExposeHeader>
    <ExposeHeader>x-amz-id-2</ExposeHeader>
    <ExposeHeader>ETag</ExposeHeader>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

PS: let me add that the image is successfully uploaded to S3

@lambda0xff lambda0xff added the to-be-reproduced Used in order for Amplify to reproduce said issue label Apr 12, 2020
@sammartinez sammartinez added the Storage Related to Storage components/category label Apr 13, 2020
@iam-yan
Copy link

iam-yan commented Apr 18, 2020

@Amplifiyer Same here. Any updates? What is the latest safe version with which these errors could be avoided?

@antonbarada
Copy link

same here

@carlosortizpacheco
Copy link

Same here

@crolly
Copy link

crolly commented Apr 22, 2020

same here

1 similar comment
@chekodev
Copy link

same here

@Amplifiyer
Copy link
Contributor

The fix will be soon available on an unstable version of aws-amplify and on a stable version when we do a production release.

@jingxizhang
Copy link

I am having the same issue, however, in downloading (instead of uploading file) from S3:
const data = await Storage.get(key, {download: true})
I got:
xhr.js:126 Refused to set unsafe header "host"
The file is successfully downloaded.

@edreinoso
Copy link

Any updates on the fix for this issue? I'm having the same trouble when trying to upload a file using Storage.put()

@Amplifiyer
Copy link
Contributor

@edreinoso are you facing this issue even with latest Amplify version? (Make sure to delete your lock files and node_modules )

@edreinoso
Copy link

@Amplifiyer thanks for the quick response.

I'm using this version of Amplify

├── aws-amplify@3.0.8
├── aws-amplify-vue@2.1.1

Based on the thread and your previous message, I'm assuming that I would have to update to a newer version.

@edreinoso
Copy link

Just tried updating to a newer version
aws-amplify@3.0.11

It worked when putting objects into a bucket.

Thanks @Amplifiyer

@mariomerlano
Copy link

Still having the same error in react.

  • "aws-amplify": "^3.0.12"

Please get this issue prioritized.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Storage Related to Storage components/category to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.