I am getting 403 for PUT requests to my site’s API while other requests seem to work (i am trying to mount an Open Journal System, a PHP project for journal publishing which uses AJAX calls to its own API, so i guess the problem is not CORS), are you aware of security policy that could be blocking me?
Far from an expert on HTTP so forgive me if i suggest an improbable cause but could NGINX be shaving part of the header and/or bluntly rejecting my request before it reaches the application?
In any case, is there a way to check the logs to see if there was an error at the PHP application level?
Ajax requests (CORS) from other websites are not supported here, these external ajax requests are blocked by the security system. Only Ajax requests under your domain will work.
Please refer to this Knowledge Base article for more information regarding the security system and what kind of stuffs it blocks:
Thank you for your replies, indeed, i don´t think its CORS related because some AJAX request do work. I have been browsing the OJS forums and saw that sometimes this can be caused by a triggering of mod_security, so i was wandering if i could see the apache logs and/or there it was possible to disable mod_security altogether? Not sure if i can do this myself or if i need to talk to an admin.
As far as I know, this should just work. AJAX on the same domain shouldn’t be an issue, and as far as I know, we don’t run mod_security on free hosting (the browser validation sufficiently protects against attacks and has fewer false positives).
I tried to open the page myself, and I get a 403 error with this JSON response:
But that might just be because I’m not logged in. Can you check in your browser’s network tab what the actual content of the response on that URL is? Because the 403 response could be generated by your website code.
After searching for help in the official OJS forums (forum.pkp.sfu.ca) it turned out that is an NGINX configuration issue which can be worked around by replacing PUT requests with POST requests but with the “X-Http-Method-Override”: “PUT” header.
I got guidance on how to modify the application code in order to apply this and now it seems to be working!