1

I am developing a REST api using PHP and Yii2. I have created a custom class for creating (POST) an entity. in that class I have the following code:

if (!$this->AuthenticateRegister($username, $token)) {
            throw new ForbiddenHttpException("Invalid token");
        }

When I try this locally (WAMP on windows) every thing works fine and I get the proper HTTP status code enter image description here But when I upload the code on the host (cpanel) I always get 200 in response enter image description here since the HTTP status codes are needed on the client side, how can I resolve this issue?

Mohammad Daei
  • 146
  • 1
  • 2
  • 10
  • Isn't this the case when you are not authenticated on local server (so 403 is thrown) but you are authenticated on remote one (and you see 200 OK)? – Bizley Dec 19 '16 at 08:26
  • wired. from the body response it looks like the Forbidden Exception has been thrown correctly. except *Content-Type* isn't `application/json` anymore. are you sure you are using the same configurations and your **LiteSpeed** server isn't doing any redirections? could you first try with a simple PHP file that emulates a 403 error like it is done [here](http://stackoverflow.com/questions/5061675/emulate-a-403-error-page) and see what it gives? also try adding `header('Content-Type: application/json');` to it. – Salem Ouerdani Dec 19 '16 at 09:26

0 Answers0