How to make Laravel return a View's “Content-Type” header as “application/javascript”?

前端 未结 6 1312
-上瘾入骨i
-上瘾入骨i 2020-12-14 08:41

I\'m trying to output a dynamic javascript file for inclusion from external websites with the [script src=\"\"] tag. As the view is using the Blade engine, it\'

6条回答
  •  情深已故
    2020-12-14 09:17

    In Laravel 5.6:

    return response()
        ->view('embedded', ['foo' => $foo])
        ->header('Content-Type', 'application/javascript');
    

提交回复
热议问题