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
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...