AWS S3 Media-Library Heroku an internal server error occurred

Hi Guys

So I installed the AWS-S3-Upload-Provider to strapi and have set everything correctly, because it works locally when I try to upload an image. I can see the image in my S3-Bucket-Dashboard.

I deployed it with heroku and it deployed successfully.
Then I tried to upload an image, but I’m getting this error:
an internal server error occurred and in console it looks like this:
failed to load resource: the server responded with a status of 500 (internal server error)

Has anyone had the problem yet?

Thank you

Kind regards, Adji

i think this happens when your environment variables aren’t setup properly

AWS_ACCESS_KEY_ID=<key>
AWS_SECRET_ACCESS_KEY=<secret>
AWS_REGION=<region>
AWS_BUCKET=<bucket>

But why does it work on localhost?

it will work in localhost if your environment is set. basically, if you used aws cli and configured the cli tools. you can check if you have ~/.aws/credentials if you have that, i think your local environment was able to pick that up and use the credentials there

I don’t have ~/.aws/credentials.

my plugin.js: /config/plugins.js

module.exports = ({ env }) => ({
upload: {
provider: ‘aws-s3’,
providerOptions: {
accessKeyId: env(‘AWS_ACCESS_KEY_ID’),
secretAccessKey: env(‘AWS_ACCESS_SECRET’),
region: env(‘AWS_REGION’),
params: {
Bucket: env(‘AWS_BUCKET’),
},
},
},
});

and my: .env file

AWS_ACCESS_KEY_ID= (KEY)
AWS_ACCESS_SECRET= (SECRET)
AWS_REGION=eu-west-3
AWS_BUCKET= (NAME OF BUCKET)

Hey @Adhshran_Kirubakaran,

The .env file is ignored by Git and is probably not on Heroku.
So you will need to set those environmental variables on Heroku as well.
Check out the official Heroku docs on how to setup ENVs.

You don’t have to do this for DATABASE_URL, because this one is set by Heroku itself.

1 Like