Closed roushan-sheik closed 1 month ago
It seems like the issue might be related to how the access token is being stored on the client side after deployment on Vercel. There are a few potential causes that could be affecting token persistence:
Token Storage Method: Ensure that you're storing the access token in a persistent storage method such as localStorage or cookies. Sometimes, storing the token in sessionStorage or memory might result in the token being cleared on page reload.
Vercel Environment: The deployment environment (Vercel) may be affecting how the token is handled. It's possible that some settings or configurations (like CORS or domain issues) are causing the token to be invalidated after a reload.
SameSite Cookies: If you're storing the token in cookies, make sure the SameSite attribute is set correctly (SameSite=Lax or SameSite=None; Secure), especially if your API calls involve cross-origin requests.
Vercel Environment Variables: Double-check the environment variables used in Vercel to ensure consistency with your local environment. Some settings, such as NEXT_PUBLIC_API_URL, may differ between local and deployed environments, affecting how tokens are managed.
Potential Debugging Steps:
Log the token to check if it's being saved properly after login and before the reload. Test the behavior by deploying to a different platform (e.g., Netlify or Heroku) to see if the issue persists there. Review your Vercel deployment logs for any errors or warnings related to the API or token handling. Feel free to provide more details about how you're handling the token storage and any related configurations. That might help narrow down the issue further.
We are encountering an issue with data fetching from the API where the data loads successfully on initial login, but after reloading the page, the data disappears or fails to persist. The access token is properly stored initially, but seems to be removed after the page refresh. The problem arises only after deploying the API on Vercel, while it works correctly in the local environment.
Steps to reproduce:
Log in and fetch data using the access token (works fine initially). Refresh the page after logging in. The access token is removed or invalidated, causing data fetching to fail. Expected behavior:
The access token should persist after page reload and the data should be fetched properly on each reload. Please provide guidance on how to resolve the access token persistence issue on Vercel, ensuring data consistency across page reloads.