简体   繁体   English

Laravel Header 请求在 Cpanel 中不返回任何内容

[英]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.在 localhost 中它可以工作,但是当我在 cpanel 中尝试时它不起作用。

The latest version of PHP does not allow _ in the header please use最新版PHP不允许_在header请使用

$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.你好,我已经为您的钥匙和宾果游戏移除了 _ 解决方案,例如,将 APP_KEY 替换为 APPKEY 和宾果游戏。 Welcome in advance提前欢迎

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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