<?php
namespace AppHttpMiddleware;
use AppPengurus;
use Closure;
use Response;
class ApiAuth
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
header('Access-Control-Allow-Origin: *');
$token = $request->header('APP_KEY');
$validateToken = Pengurus::where('token',$token)->first();
if(!$validateToken){
return Response::json(['message'=>'Anda Belum Login, Silahkan Login Terlebih Dahulu'],401);
}
return $next($request);
}
}
———————————————————
how to fix it?
in localhost it’s works, but when i try in cpanel it’s doesn’t work.
2
Answers
Hy I have got the solution
remove _ for your key and bingo
like, replace APP_KEY with APPKEY and bingo.
Welcome in advance
The latest version of PHP does not allow _ in the header please use