Closed zohaibakber closed 8 months ago
Hello @zohaibakber . You are able to call APIs under the /sign-in
route because that page currently has the Amplify configuration, which is accessed by the Amplify APIs. However Next JS doesn't behave as single page application app, where everything is loaded at once on the browser. If you want to call APIs on the client side you would need to configure Amplify in a shared route.
If you want to integrate Amplify in the server, we have a guide that you can follow: https://docs.amplify.aws/nextjs/build-a-backend/server-side-rendering/
@zohaibakber, can you let us know if the comment above from @israx helped clarify things and unblock you? Thanks!
Yea figured it out, thanks for the help
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Using above function to sign-in on route handler /sign-in in nextjs, After sign-in I can acess functions from "aws-amplify/auth" in the route but outside the route such as / or /dashboard I cant access any method like getCurrentUser(), I can see some data in local storage such as jwt token etc. stored.
Expected behavior
Resources should be available in all routes. Using WithAuthenticated from stored the user globally.
Reproduction steps
Install aws-amplify --> initialize Amplify.config() at layout -> handleSigin at route /sign-in
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response