Reputation: 1274
i'm using nuxt/axios with laravel as my backend. in my responses from laravel i send a custom header named _msg
but i cant access it. in my console.log(response)
i get only this:
but in my brower network i get the header:
how can i access it?
UPDATED
added this to my laravel middleware: this is an example if request is from manager and admin
<?php
namespace App\Http\Middleware;
use Closure;
use App\Traits\UtilsTrait;
class ManagerPlus
{
use UtilsTrait;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// return $next($request);
if($this->isMoreManager()){
$request->panelType = $this->addPanelType();
$response = $next($request);
$response->headers->set('Access-Control-Expose-Headers', 'Content-Disposition');
return $response;
}
return $this->permissionDenied();
}
}
UPDATE AFTER EXPOSE:
i did as told with my laravel/fruitcake setting and middleware and this is my new header that i get from axios. but still not getting my _msg
Upvotes: 1
Views: 1681
Reputation: 4445
What I think you need to do is:
if you are using the package https://github.com/fruitcake/laravel-cors you will have config/cors.php
and there is where you should add
'exposed_headers' => ['_msg'],
and you have to create the middleware as it's explained in the issue https://github.com/fruitcake/laravel-cors/issues/308#issuecomment-490969761
$response->headers->set('Access-Control-Expose-Headers', '_msg');
I hope it works
Upvotes: 1