Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I solve the AWS error: "The difference between the request time and the current time is too large" front-end only?

I currently have an app that allows uploads to AWS S3, the upload is handled purely from the front-end of the app in js with the aws-sdk. We had some users facing this issue mentioned in the title (The difference between the request time and the current time is too large) which prevents them from uploading properly.

I am aware of the solutions provided here, but I was wondering if there was anything I could do to make sure this doesn't happen again for any of the users, with front-end changes only. Is there a way I can make my request be in sync properly ?

I tried having some users sync their clock, but it either did not work or they didn't do it properly. Unfortunately I cannot rely on the user to fix this.

like image 547
G4bri3l Avatar asked Oct 21 '25 14:10

G4bri3l


1 Answers

I faced similar issue with S3 upload and on Cognito. Try adding correctClockSkew: true in the config block where you set accessKeyId and secretAccessKey. Like below:

AWS.config.update({
accessKeyId: awsCredentials.ACCESS_KEY_ID,
secretAccessKey: awsCredentials.SECRET_KEY_ID,
correctClockSkew: true,  
});
like image 50
Sajal Avatar answered Oct 23 '25 06:10

Sajal