async-labs / saas

Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
https://saas-app.async-await.com
MIT License
4.06k stars 674 forks source link

s3.getSignedUrl() keeps returning undefined #166

Closed marcosCapistrano closed 2 years ago

marcosCapistrano commented 3 years ago

Not sure if im doing something wrong, tried it a bunch of times and it keeps returning undefined here:

return new Promise((resolve, reject) => { s3.getSignedUrl('putObject', params, (err, data) => { const parsedUrl = url.parse(data); <<<<<<<<<<< HERE "data" is undefined

  const returnData = {
    signedRequest: data,
    url: `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.pathname}`,
  };

  if (err) {
    console.error(err);
    reject(err);
  } else {
    resolve(returnData);
  }
});

});

Files from 5-begin can be used for testing

klyburke commented 3 years ago

@marcosCapistrano Thanks for reporting. I will run 5-begin and see if I can reproduce the error.

klyburke commented 2 years ago

@marcosCapistrano I ran the 5-begin code and did not see that data in that line of code is undefined.

To confirm that data is not undefined here, I went to the aws-s3.ts file of 5-begin and added console.log(data) like so:

Screenshot from 2021-09-14 14-10-44

I started the app, went to Your Settings page and uploaded a new avatar. After that, my server logs print data object:

Group 141


Please check up set up for your AWS S3 bucket. Under Permissions, make sure you deselected Block all public access:

Screenshot from 2021-09-14 14-28-12

Also under Permissions, make sure your CORS policy is correct:

Screenshot from 2021-09-14 14-30-43

Finally, check that you have all necessary environmental variables saved in your appropriate .env files (both app and api).


Let me know if you still have trouble. Feel free to create a public repo with your code, and I will test.

marcosCapistrano commented 2 years ago

Oh i must have done something wrong, i'll try it as soon as I can, Thanks!!

klyburke commented 2 years ago

Hi @marcosCapistrano - were you able to figure out the issue? Let me know if you still have trouble.