CodeIgniter Forums

Full Version: Problem in Filter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ihave code in Filter like this
PHP Code:
<?php

namespace App\Filters\API;

use 
CodeIgniter\Filters\FilterInterface;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Config\Services;

class 
GuestRequest implements FilterInterface
{
 
   public function before(RequestInterface $request)
 
   {

 
        //$req  = ( $request->getMethod()=='post' && $request->isAJAX() == TRUE$
 
       $req $request->getMethod();
 
       $ajx $request->isAJAX();

 
       if$ajx == true )
 
       {
 
               Config('App')->data = (object)[$req$ajx];
 
               Config('App')->time microtime(true);
 
               return true;

 
       }


 
       return Services::response()
 
           ->setStatusCode(401);

 
   
In local (OS : linix mint, php 7.2) run normal
in VPS (OS Centos, php 7.2)
always return 401, although my codes change to
if( $ajx == false)
I think you've already solved that. But if a Response instance is returned the request will be responded.
Oh, it looks like you can not return anything not empty. Even then the code should not be executed... Have you found a solution?