Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 38808d5

Browse files
committed
fix content-type of .js and .css files
1 parent 3d381c4 commit 38808d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Server/Manager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ public function onRequest($swooleRequest, $swooleResponse)
292292
protected function handleStaticRequest($illuminateRequest, $swooleResponse)
293293
{
294294
$uri = $illuminateRequest->getRequestUri();
295-
if (strpos($uri, '.php') || strpos($uri, '.htaccess') || strpos($uri, '.config')) {
295+
$blackList = ['php', 'htaccess', 'config'];
296+
$extension = substr(strrchr($uri, '.'), 1);
297+
if ($extension && in_array($extension, $blackList)) {
296298
return;
297299
}
298300

@@ -304,7 +306,13 @@ protected function handleStaticRequest($illuminateRequest, $swooleResponse)
304306
}
305307

306308
$swooleResponse->status(200);
307-
$swooleResponse->header('Content-Type', mime_content_type($filename));
309+
$mime = mime_content_type($filename);
310+
if ($extension === 'js') {
311+
$mime = 'text/javascript';
312+
} elseif ($extension === 'css') {
313+
$mime = 'text/css';
314+
}
315+
$swooleResponse->header('Content-Type', $mime);
308316
$swooleResponse->sendfile($filename);
309317

310318
return true;

0 commit comments

Comments
 (0)