Back

Help Needed: 404 Errors on Page Refresh After Deploying to Vercel (Probably Cookie-Auth-API Related)

  • 0
  • Auth
  • Web
  • Cloud
markibook
1 Aug, 2024, 03:29

Good afternoon, everyone. I need help solving the following error that I still can't quite identify, but I hope you can help me understand what might be happening.

I managed to get my page running locally. When I run npm run dev, it works perfectly, but when I deployed it on Vercel, I have 404 error issues when I try to refresh a page.

What I've noticed is that I can do everything as long as I don't refresh the page and keep the cookieFallback generated by createEmailPasswordSession. Somehow, that cookie is always at the root, at "/", and there's no problem there—I can always go back and refresh. However, when I navigate and refresh, it gives a 404 error.

I've been researching the documentation and several official videos from the Appwrite YouTube channel, but I haven't found anything very up-to-date on how to do SSR, if that has anything to do with the problem I'm having. In one of the videos, I saw them set a setKey in a Client, which tells me it can't be done, and everywhere it says it's not appropriate to do so. Therefore, I am quite lost on how to proceed. My intuition tells me that ensuring the cookie is always in the browser would solve this problem.

The other alternative I tried was to check if I am verified every time I go to a new page within my site. This seemed to solve the problem, but it added a new issue where every time the page loaded, it took quite a while, presumably because it had to make the request and that takes time. The cookie path was faster.

I welcome any kind of help; everything is appreciated. I am extremely lost on this but have this project quite advanced and am very excited to see it working. Solving this would be incredible, and learning more about it even more so!

Thanks to everyone in advance.

I am attaching images of my code so you can see how I am handling things so far:

TL;DR
Developers are experiencing 404 errors on page refresh after deploying to Vercel, possibly related to Cookie-Auth-API. The issue seems to stem from cookieFallback being at the root. To resolve, ensure cookies are always in the browser and verify authentication on every new page, although this may cause loading delays. Consider optimizing authentication check for better performance.
markibook
1 Aug, 2024, 03:30
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more