Ive tried everything, but get CSRF Error

What I am trying to do: I have syncthing on my mobile device and my laptop, when I open emacs, I want it to do a rescan from my phone’s side and sync all changed files to my laptop. I have it setup to sync from my laptop to my phone with this terminal command when I close emacs:

curl -X POST -H “X-API-Key: {{API REDACTED}}” http://localhost:8384/rest/db/scan

and it works perfectly but it would be even better for it to sync the stuff I edited on my phone to emacs when I open it but everytime I put the curl -X POST -H “X-API-Key: {{PHONE API REDACTED}}” http://localhost:8384/rest/db/scan

it just gives me a CSRF error, I have been trying to get this to work for 2 days now, any help?

I believe the Android app has HTTPS enabled by default, so you need to use https://localhost:8384/rest/db/scan instead of just http://. Also, I’m sure you’re aware that localhost refers to the current device, so unless you’re running curl on Android itself, you need to replace it with the actual IP address of the phone.