The-Commit-Company / frappe-react-sdk

React hooks for Frappe
https://frappe-react.vercel.app
MIT License
110 stars 36 forks source link

CSRFTokenError on some browsers when useFrappePostCall is called #56

Closed chipohameja closed 8 months ago

chipohameja commented 9 months ago

After deployment on a VPS, I get CSRFTokenError 400 BAD REQUEST on most browsers when useFrappePostCall is called.

{exc_type: "CSRFTokenError",…} exc_type : "CSRFTokenError" _server_messages : "[\"{\\\"message\\\": \\\"Invalid Request\\\", \\\"title\\\": \\\"Message\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1, \\\"__frappe_exc_id\\\": \\\"e0dc4989030a221d2134e96f79a87661beee555e015fccca7439d7c1\\\"}\"]"

image

I checked the Network Headers tab and confirmed the csrftoken is passed image

Everything works well on localhost. After deployment, it doesn't work on all browsers tested so far, apart from the chrome browser on my laptop. Chrome on other laptops doesn't work

nikkothari22 commented 9 months ago

@chipohameja This might be related to your backend, since Frappe React SDK is sending the CSRF token it gets