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

downloadRequestHeaders config does not work #17

Closed
sananguliyev opened this issue Apr 22, 2020 · 5 comments
Closed

downloadRequestHeaders config does not work #17

sananguliyev opened this issue Apr 22, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@sananguliyev
Copy link

sananguliyev commented Apr 22, 2020

Hi,

I am trying to read data from s3 and due to CORS I have to add Origin header but it looks like it's not setting the header as expected in Chrome. I now it should be added by default by browser but I do not see any origin header in the network tab.

Chrome: does not work
Safari: Refused to set unsafe header "Origin"
Opera: works but gives error papaparse.js:699 Refused to get unsafe header "Content-Range"

readRemoteFile(
    'https://some-s3.url.com/sample.csv',
    {
        downloadRequestHeaders: {
            'Origin': 'http://example.com/'
        },
        step: (row) => {
            console.log('Row:', row.data)
        },
        complete: (results) => {
            console.log('Results:', results)
        }
    }
);

Thanks in advance.

@Bunlong
Copy link
Owner

Bunlong commented Apr 22, 2020

@sananguliyev The problem is you haven't allowed origin header on amazon s3. You can follow this guidance to solve this problem. If it works please let me know. Thanks!

@sananguliyev
Copy link
Author

I already added the CORS configuration to S3. It's an issue on Chrome level. I disabled out of blink on Chrome and it's gone.

Do you have any idea about Refused to get unsafe header "Content-Range" this error?

@Bunlong
Copy link
Owner

Bunlong commented Apr 22, 2020

@sananguliyev Could you please follow this guidance and try the following CORES configuration:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <CORSRule>
    <AllowedOrigin><!-- insert your origin here --></AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedHeader>Range</AllowedHeader>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <ExposeHeader>Accept-Ranges</ExposeHeader>
    <ExposeHeader>Content-Range</ExposeHeader>
    <ExposeHeader>Content-Encoding</ExposeHeader>
    <ExposeHeader>Content-Length</ExposeHeader>
    <AllowedHeader>Authorization</AllowedHeader>
  </CORSRule>
</CORSConfiguration>

@sananguliyev
Copy link
Author

Thanks. I will try to expose headers, too.

@Bunlong
Copy link
Owner

Bunlong commented Apr 23, 2020

@sananguliyev Yes, you are welcome. Thanks!

@Bunlong Bunlong added the bug Something isn't working label May 1, 2020
@Bunlong Bunlong self-assigned this May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants