I'm using appwrite in a client without SDK.
I'm trying to use data.updateDocument() method but getting CORS error.
However GET, POST and other methods work well.
I'm not sure, but I think the problem is with the PATCH method.
How can I solve this? ( i'm using NextJS14 ).
Summary
The user is experiencing a CORS error when using the `data.updateDocument()` method in appwrite on the client side. They suspect it may be related to the `PATCH` method. They have already enabled all permissions in the collections and there are relationship attributes in the collection. However, the request works fine with Postman.
Possible solutions:
- Check the permissions on the collection and document.
- Disable server-side rendering in NextJS for easier development.
- Instead of using the `appwrite` client request on the client side, use `node-appwrite` in NextJS as a workaround.
k_vasen
Rank 1: Thread
Jan 6, 2024, 12:14
Did it work before?
Мухаммадамин
Rank 1: Thread
Jan 6, 2024, 12:41
@k_vasen
No, it didn't work from the start
ZachHandley
Jan 6, 2024, 19:08
can you show code
ZachHandley
Jan 6, 2024, 19:08
please
Drake
Jan 6, 2024, 21:23
What are the permissions on the collection and document?
Мухаммадамин
Rank 1: Thread
Jan 7, 2024, 06:16
@ZachHandley Here is the code
Мухаммадамин
Rank 1: Thread
Jan 7, 2024, 06:20
@Steven I have enabled all document permissions
Мухаммадамин
Rank 1: Thread
Jan 7, 2024, 06:46
But with postman, it is working
Drake
Jan 7, 2024, 20:24
Postman typically ignores CORS
Drake
Jan 7, 2024, 20:25
Does the collection have any relationship attributes?
Мухаммадамин
Rank 1: Thread
Jan 7, 2024, 20:31
@Steven yes, columnId is a relationship attr that related to columns
Drake
Jan 7, 2024, 20:32
What are the permissions on that collection?
ZachHandley
Jan 7, 2024, 20:53
ah smart
Мухаммадамин
Rank 1: Thread
Jan 8, 2024, 07:23
@Steven I've enabled all permissions in all collections
Drake
Jan 8, 2024, 22:00
And you're getting the same error still?
Мухаммадамин
Rank 1: Thread
Jan 9, 2024, 05:36
@Steven yes
Мухаммадамин
Rank 1: Thread
Jan 9, 2024, 05:41
Here I created route handler, this is a request from server with "node-appwrite" and it works fine.
But it gives CORS on update when I try to do a client request with "appwrite" on the client side ?
Мухаммадамин
Rank 1: Thread
Jan 9, 2024, 05:43
@Steven Is it possible to set headers for the "updateDocument" of "appwrite" function on the client side?
ideclon
Jan 9, 2024, 07:01
No, that would be a security vulnerability
D5
Jan 9, 2024, 08:13
This code seems not to to be the code you should be using
D5
Jan 9, 2024, 08:14
What's the SDK version you're using?
Мухаммадамин
Rank 1: Thread
Jan 9, 2024, 10:46
@D5 here is the version, but actually the main problem is not in SDK but in "appwrite", cuz I'm trying to use it on client side, I think you understand that
Мухаммадамин
Rank 1: Thread
Jan 9, 2024, 11:53
since an update method of appwrite is giving CORS, I will use node-appwrite in Nextjs , i think this is the only way I can do
D5
Jan 9, 2024, 11:54
NextJS uses server-side rendering. You should disable it for now for an easier development