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

CORS error (no permissions) #71

Open
sofibegino opened this issue Aug 31, 2022 · 0 comments
Open

CORS error (no permissions) #71

sofibegino opened this issue Aug 31, 2022 · 0 comments

Comments

@sofibegino
Copy link

sofibegino commented Aug 31, 2022

I am trying to upload photos through the react-dropzone-s3-uploader but I am not sure how to give access to the bucket. I get a CORS error and a 403 forbidden.

This is what I have so far

const handleFinishedUpload = (info) => {
    console.log("File uploaded with filename", info.filename);
    console.log("Access it on s3 at", info.fileUrl);
   
  };

const uploadOptions = {
    server: "http://localhost:3000",
    accept: 'image/*',
    autoUpload: true
    };
  const s3Url = "https://mybucket.s3.sa-east-1.amazonaws.com";
  
  <DropzoneS3Uploader
      onFinish={handleFinishedUpload}
      s3Url={s3Url}
      maxSize={5000*5000}
      upload={uploadOptions}
 />

Then in the server.js

import reactS3 from "react-dropzone-s3-uploader/s3router.js";

app.use('/s3', (reactS3)({
  bucket: 'mybucket',                      
  region: 'us-east-1',                         
  headers: {'Access-Control-Allow-Origin': '*'}, 
  ACL: 'private',                           
}));

And in the .env file I have the access and secret access keys.

I'd appreciate any help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant