Back

Image File Preview Returns 404

  • 0
  • Storage
SenZi
15 Feb, 2023, 18:35

yes i am, the endpoint is using https

TL;DR
Support thread: Developers seek help in displaying image file previews from Appwrite's storage bucket across different domains, facing a 404 error even with authentication. Solution involves ensuring same base domain for Appwrite and app, using HTTPS, and considering 3rd party cookie restrictions. Download might be successful, but preview could fail due to browser settings. Solution: Ensure Appwrite and app are on the same base domain, access Appwrite using HTTPS, and check for proper cookie handling across domains for successful file preview.
Drake
15 Feb, 2023, 18:35

Are both being accessed with localhost as hostname?

SenZi
15 Feb, 2023, 18:36

no, the instance is run on a server with a domain name, i dont have docker installed for local instance.

Drake
15 Feb, 2023, 18:37

You might need to have your app running on the same base domain. You can edit your hosts file if you don't want to actually set up a DNS record

SenZi
15 Feb, 2023, 18:38

So it wont work across different domains? Is it limited to file preview or every storage bucket functions including download?

Drake
15 Feb, 2023, 18:39

Download should work fine. View may not. This is due to browsers blocking 3rd party cookies

SenZi
15 Feb, 2023, 18:40

Also, opening the url directly on my browser gives the same error

TypeScript
{"message":"The requested file could not be found.","code":404,"type":"storage_file_not_found","version":"1.2.0"}
Drake
15 Feb, 2023, 18:40

Your url includes the project right?

SenZi
15 Feb, 2023, 18:40

Yes

SenZi
15 Feb, 2023, 18:41

but just adding &mode=admin at the end of the same url without changing any other value shows the preview...

Drake
15 Feb, 2023, 18:42

Don't include that. Mode admin would attempt to access it as your admin account thats used for the appwrite console

SenZi
15 Feb, 2023, 18:42

I am authenticated in the AppWrite dashboard so that works, but opening the url without the admin mode does not work.

SenZi
15 Feb, 2023, 18:45

download returns 404 too..

SenZi
15 Feb, 2023, 18:46

is there a way to get the file across different domains using client web sdk

Drake
15 Feb, 2023, 18:46

Not using the IMG html element

Drake
15 Feb, 2023, 18:47

What's the problem with having the two share the same base domain?

SenZi
15 Feb, 2023, 18:49

there will be another sub product on a different domain, so sharing user info across different domains would be useful.

Drake
15 Feb, 2023, 18:50

Sorry I don't quite follow

SenZi
15 Feb, 2023, 18:51

users will create an account on abc.com but we host a different website which is a sub product of abc.com on xyz.com, so sharing user information from abc.com to xyz and not having to create different appwrite instances or making user create multiple accounts would be useful i guess.

Drake
15 Feb, 2023, 18:53

So it's possible to have your project accessed on multiple domains. Your abc.com can hit Appwrite at appwrite.abc.com. xyz.com can access appwrite.xyz.com, etc. this way the cookies will pass through fine

SenZi
15 Feb, 2023, 18:55

so are you suggesting to create a appwrite instance on xyz.com with the same backend (database, storage) as abc.com?

Drake
15 Feb, 2023, 18:55

No, they all use the same Appwrite instance, but you set up custom domains (cname DNS records that point to your Appwrite main domain)

https://appwrite.io/docs/custom-domains

SenZi
15 Feb, 2023, 18:56

Oh gotcha

SenZi
15 Feb, 2023, 18:57

I guess this could work and for localhost i can use the hosts file as you suggested earlier

SenZi
15 Feb, 2023, 18:58

Thanks for the help, i would give this a try

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