How to post data to my cakephp app from outside?

I have mobile app i can post data to my cake app but i got error cors error, what should i do for that ? i tried set cors my app.php but not working Any help ? we are use latest version cake.

Read over this:


Also a past topic on cors: Cakephp 4 : CORS [workaround/solved]

All those links i tried my cakephp app but didn’t worked. can you Please help me out this issue what’s my going my code, I tried that plugin also not worked in my code.

Also , I installed but not works Please suggestion, Also tries the past topic and it’s code but not works. Please any help.

If I am comment the code in Application.php

->add(new CsrfProtectionMiddleware([
‘httponly’ => true,

them it’s works but if comment remove then get an following error

Missing or incorrect CSRF cookie type

Please suggest any idea what’s wrong i doing in this code

I’ve found debugging a system-wide issue of this scale there’s 2 approaches.

If your app is relatively small then make a copy of it, and start knocking out all the forms and less relevant stuff until you have a very small app that duplicates this behaviour and post the code for that.

If its too big just bake a brand new app and put into the minimum code needed to do what you want to. If it works then compare what’s different (and if you can’t find that go back to approach one) and if it doesn’t work then post that code!

And in either case, try running your dummy app on another server.

There could be a setting misconfiguration with your server (eg. Apache), with the SSL certificate, with the PHP, with the .htaccess - in the full stack about the only thing which it probably isn’t is the SQL engine!

Hey @spadeX,
If csrf token is giving an error so why not remove the csrf token in your controller initialize() function inside the csrftoken code.

I already solved that problem without removing any code.