简体   繁体   中英

Laravel Header Request Doesn't Return Anything in Cpanel

<?php

namespace App\Http\Middleware;

use App\Pengurus;
use Closure;
use Response;

class ApiAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $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.

The latest version of PHP does not allow _ in the header please use

$token = $request->header('APP-KEY')

Hy I have got the solution remove _ for your key and bingo like, replace APP_KEY with APPKEY and bingo. Welcome in advance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM