
I am using appwrite cloud for the first time , and was trying to fetch documents with the help of listDocuments methods but i am getting CORS error in the browser.
const client = new Client(); const databases = new Databases(client); client.setEndpoint( "https://cloud.appwrite.io/v1/databases/databaseID/collections/collectionId/documents" ); client.setProject(appwrite_project_id);
const promise = databases.listDocuments(
databaseId,
colectionId
);
promise
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
This is the code that I am using. The error i am getting :

This is the hostname I have used in the appwrite dashboard.

Try to change the endpoint to this
const client = new Client().setEndpoint('https://cloud.appwrite.io/v1')

The rest of the path will be enter by the function it self, in your case the listDocuments
for example.

Hey thanks for replying , but I am still facing the same issue.

Recheck the appwrite_project_id

Rechecked! But still the error persists.

By the way , is there any way i can set request headers ? I have gone over the docs but didnt found anything.

If you're using the SDK then you can't

Can you share the error now?

yeah , i am using appwrite sdk

Still i am getting the same error.

Sometime it can happened because of the double slash,

Can you make sure there's only one?

Thanks , that error is resolved, now i am getting a different error

Okay, for that you'll need to make sure that your collection has set permissions for that user

You can go to your collection settings and check over there.

I have updated the permissions for both specific users and any user , but still the same error is coming.


You get the same not authorized
error?

Yes

You still facing the error?

No , it is fixed now , thanks for the help.

<:appwriteupvote:899677724615016528>

[SOLVED] CORS Error - No 'access-control-allow-origin'
Recommended threads
- How to reduce DB Reads?
I just noticed that I hit the 500k db reads limit on my very small next js app with the most data being present in one collection having around 50 documents. ...
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- Pending upload some file, but not for ot...
When upload this file, always got pending. But when I upload another file, it works. Why?
