由jwt

时间:2017-04-03 13:55:45

标签: vue.js vuejs2

有没有办法获得受jwt保护的图像?

laravel route:

$api->get('images/{slug}', ['uses'       => 'App\Api\V1\Controllers\ImagesController@show']);

laravel show method:

public function show($imgid)
{
    if(Auth::check())
    {
        $path = Config::get('fms.images.thumbnail') . '/' . $image->thumbnail;
        return \Intervention\Image\Facades\Image::make($path)->response();
    } else
    {
        return null;
    }
}

vue img:

  <img :src="imgurl(photo.id)">

vue imgurl method

imgurl(imgid) {
   return "/api/images/" + imgid
}

返回400,因为我没有通过身份验证

感谢

1 个答案:

答案 0 :(得分:1)

有一个Vue.js库,它允许传递auth标头:

https://www.npmjs.com/package/vue-auth-image