Back

CORS issue with only database.updateDocument() method

  • 0
  • Web
Мухаммадамин
6 Jan, 2024, 10:43

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 ).

TL;DR
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
6 Jan, 2024, 12:14

Did it work before?

Мухаммадамин
6 Jan, 2024, 12:41

@k_vasen No, it didn't work from the start

ZachHandley
6 Jan, 2024, 19:08

can you show code

ZachHandley
6 Jan, 2024, 19:08

please

Drake
6 Jan, 2024, 21:23

What are the permissions on the collection and document?

Мухаммадамин
7 Jan, 2024, 06:16

@ZachHandley Here is the code

Мухаммадамин
7 Jan, 2024, 06:20

@Steven I have enabled all document permissions

Мухаммадамин
7 Jan, 2024, 06:46

But with postman, it is working

Drake
7 Jan, 2024, 20:24

Postman typically ignores CORS

Drake
7 Jan, 2024, 20:25

Does the collection have any relationship attributes?

Мухаммадамин
7 Jan, 2024, 20:31

@Steven yes, columnId is a relationship attr that related to columns

Drake
7 Jan, 2024, 20:32

What are the permissions on that collection?

ZachHandley
7 Jan, 2024, 20:53

ah smart

Мухаммадамин
8 Jan, 2024, 07:23

@Steven I've enabled all permissions in all collections

Drake
8 Jan, 2024, 22:00

And you're getting the same error still?

Мухаммадамин
9 Jan, 2024, 05:36

@Steven yes

Мухаммадамин
9 Jan, 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 ?

Мухаммадамин
9 Jan, 2024, 05:43

@Steven Is it possible to set headers for the "updateDocument" of "appwrite" function on the client side?

ideclon
9 Jan, 2024, 07:01

No, that would be a security vulnerability

D5
9 Jan, 2024, 08:13

This code seems not to to be the code you should be using

D5
9 Jan, 2024, 08:14

What's the SDK version you're using?

Мухаммадамин
9 Jan, 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

Мухаммадамин
9 Jan, 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
9 Jan, 2024, 11:54

NextJS uses server-side rendering. You should disable it for now for an easier development

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more