π Bug Report: Origin localhost not allowed when fetching file
lkoehl opened this issue Β· comments
π Reproduction steps
Running a local instance of appwrite, use Safari as a browser and fetching data from a link returned by getFileView
const url = storage.getFileView(BUCKET_ID, fileId);
axios
.get(url.href)
.then((response) => console.log(response))
.catch((error) => console.log(error));
π Expected behavior
Returns the data from the file.
π Actual Behavior
[Error] XMLHttpRequest cannot load http://localhost/v1/storage/buckets/62e3ed0fc097798c4bfe/files/62e3ed7e4eafee1a50d1/view?project=625ec35b68a2dcb2d0fd due to access control checks.
[Error] Failed to load resource: Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. Status code: 200 (view, line 0)
π² Appwrite version
Version 0.9.x
π» Operating system
MacOS
𧱠Your Environment
No response
π Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
π’ Have you read the Code of Conduct?
- I have read the Code of Conduct
@lkoehl, thanks for raising this issue! π I tried to reproduce your issue, but I was able to successfully fetch a markdown file and get the text. Would you please make sure your project ID is correct and use https for your endpoint?
@stnguyen90 thanks. It's works with Safari when setting the endpoint to https://localhost/v1
. Maybe the README needs an update?
Lines 47 to 58 in cfc9baa
@gewenyu99, thoughts on making all of our examples use HTTPS since sometimes there's weird behavior when using HTTP (due to how browsers handle cookies and/or redirects)?
@gewenyu99, we seem to be inconsistent. Most are HTTPS except:
I agree. I want to make everything https. This will be true esp. for cloud anyway. I have this written down in the doc contribution guide draft :)
Localhost and https can create issues on top without any configuration. We should double check that.
Thinking about local dev servers that connect to Appwrite which don't support https oob. Then you run into http -> https conflicts.
This issue only occurs in browsers, that's why non-browser sdks might target https.
Localhost and https can create issues on top without any configuration. We should double check that.
Thinking about local dev servers that connect to Appwrite which don't support https oob. Then you run into http -> https conflicts.
This issue only occurs in browsers, that's why non-browser sdks might target https.
I think the real solution will be when we have cloud ;)
Then we can just use the cloud URL as the default example.