K
K
KlokovDdmitriy2017-01-12 11:31:26
API
KlokovDdmitriy, 2017-01-12 11:31:26

How to get custom headers from a request in Laravel 5?

Testing API for mobile applications using Postman. I'm trying to send tokens in headers, but there are no headers in the request object. If I send any standard content-type or accept headers, then I can get their values, but custom headers are not visible at all: neither their keys nor values.
For example, I send headers like this:
45942b758afe4ab6b646ff0e14cb771a.png
Then, I output them:

<?php 
namespace App\Http\Controllers\API\MobileApp;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class OrdersController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        dd( $request->headers);
    }
}

As a result, I get all the headers, except for tokens:
4eb360d2cd4c4d808173ebdb8bd0a4e7.png
Maybe I don’t know something, and such headers, in principle, cannot be transmitted? Or is there some kind of filter in Laravel that doesn't allow passing non-standard headers? Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2017-01-12
@KlokovDdmitriy

App-Token, App-Auth, not App_Token, App_Auth.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question