dotibrb048760 2017-10-16 21:15
浏览 51

资源解释为样式表,但由于返回File :: get in route而在Laravel中使用MIME类型进行传输

I am trying to limit the access to one of my public sub-folder : /templates/sb-admin-2/. I have moved the folder under resources folder tracker sub-folder and defined a route as fallow:

Route::middleware(['auth:admins'])->group(function () {
    Route::get('/templates/sb-admin-2/{path?}', function () {
        return File::get(resource_path('tracker' . ltrim($_SERVER['REQUEST_URI'])));
    })->where(['path' => '.*']);
});

I have issue with loading css, browser console warning:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://<myDomain>/templates/sb-admin-2/dist/css/sb-admin-2.css"

javascrips also have issues. I was wondering if anyone could help me to fix the issue? I'm using Laravel 5.4 and this is happening on my local environment. I'm using homestead within local environment.

Update: the content of the css are identical. however the headers are different.

After moving the folder:

Response Headers:

Cache-Control:no-cache, private
Cache-Control:no-store, no-cache, must-revalidate
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Tue, 17 Oct 2017 00:21:02 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Pragma:no-cache
Server:nginx/1.13.3
Set-Cookie:XSRF-TOKEN=...; expires=Tue, 17-Oct-2017 02:21:02 GMT; 
SetCookie:.. Max-Age=7200; path=/; HttpOnly
Transfer-Encoding:chunked
X-Powered-By:PHP/7.1.10-1+ubuntu16.04.1+deb.sury.org+1

Request Headers:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*//*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:..
Host:<MyDomain>
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Before moving the folder:

Response Headers:

Accept-Ranges:bytes
Connection:keep-alive
Content-Length:781
Content-Type:text/css
Date:Tue, 17 Oct 2017 00:21:29 GMT
ETag:"59ce571f-30d"
Last-Modified:Fri, 29 Sep 2017 14:22:23 GMT
Server:nginx/1.13.3

Request Headers:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*//*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie...
Host:<MyDomain>
Pragma:no-cache
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题