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
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- Cloud function deploy stucks in processi...
Been trying for the last hours to deploy my function but for whatever reason, alwasy stuck on processing!