Artisan serve send assets with response headers embedded

耗尽温柔 提交于 2020-01-03 05:37:32

问题


Maybe this is something obvious but I'm having a hard time, I just found out that my local PHP environment is delivering static files with the response headers embedded.

This is Laravel 4.1.26 with PHP 5.5.11 on Fedora 20, already tested laravel serve and php -S localhost:8000 server.php, both with equal results.

I tried with Firefox, Opera and Chromium, it looks like is displaying the raw binary response:

This is causing errors on all my js files.

For what is worth I tried curl and wget -q -O - and the responses are ok, no headers displayed. This looks like PHP's built-in server issue, where should I dig first?

EDIT:

This is not a PHP thing, it has something to do with Laravel's emulation of mod_rewrite with the file "server.php", if I step on the public folder and launch the server with php -S (ignoring server.php and laravel serve) then is all fine.

EDIT2:

Just narrowed the search, artisan serve runs ok in Debian 8 Jessie with the same PHP version (5.5.11), something is different in the Fedora environment.


回答1:


just change:

if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
   return false;
}

to

if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
ob_end_clean ();
   return false;
}

it solved it for me



来源:https://stackoverflow.com/questions/23274475/artisan-serve-send-assets-with-response-headers-embedded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!