PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, April 18, 2022

[FIXED] How to get header request value in my laravel app on production?

 April 18, 2022     apache, laravel     No comments   

Issue

In my laravel app request header value returns an expected value on my localhost. but when i upload project on server its returning null value. I created a middleware Authkey.php

public function handle(Request $request, Closure $next)
{
    $token = $request->header('API_ACCESS_KEY');
    dd($token);
    if ($token !=env('API_ACCESS_KEY')) {
           return response()->json(['message' => 'Unauthorized'],401);
    } 
    return $next($request);
}

Solution

Replace the API_ACCESS_KEY in your request with Api-Access-Key , also update it at your middleware too ,

as the underscores are invalid characters for header names,

Translation of headers to environment variables is more strict than
 before to mitigate some possible cross-site-scripting attacks via header injection.
 Header names containing invalid characters (including underscores) are
 no longer converted to environment variables.

for more info please check apache new features



Answered By - Omar Tammam
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing