Open kolodi opened 8 months ago
Hi @kolodi thank you for opening this issue. I see that you are using an Next JS app, does this issue seem to be specific to Server Side pages? Or do you see it regardless of client side/server side usage?
Also I'm working through testing this myself but curious if you have had a chance to see this happen on a SPA app.
Hi @kolodi thank you for opening this issue. I see that you are using an Next JS app, does this issue seem to be specific to Server Side pages? Or do you see it regardless of client side/server side usage?
Also I'm working through testing this myself but curious if you have had a chance to see this happen on a SPA app.
Hi @nadetastic, You are tight. I have older "vanilla" js/ts (webpack) SPA application. It is using the Storage in the same way as this new Next app, infact, it is using the same Amplify backend (it was a single module of the project that I am almost dome migrating under the common next js application). And the browser upload to S3 it is working fine there, even after 1 hour after login.
Btw, I have ssr=true in my Amplify config.
import config from '../src/aws-exports';
Amplify.configure({
...config,
ssr: true,
});
So it must be related to SSR in next.js. Any expert in this area can take a look?
@kolodi it looks like you are using an older major version of aws-amplify
(v5.x.x) which had limited support for SSR. If so, I recommend upgrading to the latest major version (v6) which as improved support for SSR. Here are some reference documentation on how you can upgrade and use SSR:
Thx for reply @nadetastic . I was considering passing on v6 and started doing it in a separate branch, but the project is quite big now, and I have realized it would take a lot. Do you think the SSR limitation for Storage can be fixed in v5 somehow. Maybe we can fix it faster than migrating all our projects to v6.
I’m facing the same problem as well. I’m not using Next.js. Same amplify version, apparently it does not refresh the temporary security credentials during upload and then fails after 1hr with an ExpiredToken error. Then I have to refresh the page to get new temporary security credentials.
I ended up migrating to v6 and not using ssr
I ended up migrating to v6 and not using ssr
I upgraded to v6 today, but I'm still getting an "ExpiredToken" error after exactly one hour when uploading files. I'm not using ssr as well.
My investigation suggests that the temporary security credentials used for uploading aren't being refreshed. These credentials expire after one hour. The code seems to check the token's expiration before each upload part, but incorrectly logs that it's still valid even when it's not.
Some Logs:
Then it stops completely.
It's suggested at Expired Token: The Token is Expired - Managing Tokens Properly #12734 that we should migrate from Amplify V5 to V6.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication, Storage
Amplify Categories
auth, storage
Environment information
Describe the bug
Storage operations fail due to token expiration. Amplify should take care of refreshing tokens automatically but it is not working for Storage for some reason. I still can do other operations like calling GraphQL and REST APIs, but the Storage is working only when refreshing completely the page.
Expected behavior
Storage.put ot Storage.get should be using refreshed tokens as other services do.
Reproduction steps
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
Additional Storage configurations
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response