I use Appwrite storage to store some images and generate previews for them. When I develop my React app locally, all works well. However when I deploy it to Vercel, images won't load and I get the 401 unauthorized response from the server.
I've added Vercel deploymnet to my platforms, and otherwise contacting Appwrite works (e.g. to work with the database).
Summary
Issue: Unable to load images when hosted on Vercel
Solution: The problem is likely caused by third-party cookie restrictions in modern browsers. To resolve this, try the following steps:
1. Give any permissions to the image file to address the issue.
2. Try accessing the website in incognito mode.
3. Log out and back in to the application to see if that resolves the problem.
4. Check if the fallbackCookies are stored in the browser under the localhost but not the deployed website's host.
If none of these steps work, it may be necessary to purchase a custom domain to prevent third-party cookie issues.
Toli
Rank 1: Thread
Nov 20, 2023, 22:43
Update: for some reason, when I logged out and back in to my application, it worked. I suspect has to do something with the fallbackCookies: e.g. they could have been stored in the browser under the localhost but not the deployed website's host...
Toli
Rank 1: Thread
Nov 20, 2023, 23:20
Update 2: from the mobile device, the workaround of logging out and back in did not work.
Can you try giving any permissions to the file and see if that addresses the issue? If it does, it might be a 3rd party cookie problem
Toli
Rank 1: Thread
Nov 21, 2023, 06:55
Setting the permission of the database to Any solved it. So to prevent the 3rd party cookies issue, the only way is to own a custom domain? Is there any way to resolve this problem without purchasing a domain and without setting the permissions to Any?
D5
Moderator
Nov 21, 2023, 08:38
Yes and not possible
D5
Moderator
Nov 21, 2023, 08:38
A domain is needed for first party cookies
Toli
Rank 1: Thread
Nov 21, 2023, 08:44
[SOLVED] Unable to load images when hosted on Vercel
VincentGe
Nov 21, 2023, 14:22
Yeah so third party cookies is a problem caused by new security features of modern browsers