When I use the same access keys generated from the AWS IAM on local server it works as expected but when I try to use the s3 from my node application on cPanel it gives me this error.
My frontend is in React deployed on vercel and using express app on my cPanel. Any Solution
I have tried and tested it on local server which is working fine.
const { S3Client } = require("@aws-sdk/client-s3");
const multer = require("multer");
const multerS3 = require("multer-s3");
const s3 = new S3Client({
region: process.env.AWS_REGION, // Specify the AWS region from environment variables
credentials: {
accessKeyId: process.env.AWS_ACCESSKEYID, // Access key ID from environment variables
secretAccessKey: process.env.AWS_SECRETACCESSKEY, // Secret access key from environment variables
},
});
This issue likely occurs due to the absence of proper environment variables on your cPanel server. Ensure that AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION are set up correctly in your cPanel environment. Also you can add them via the cPanel's environment variables section or include them in your .env file if supported.