find($theme); $themeRoot = realpath($loadedTheme->path()); abort_unless($themeRoot !== false, 404); $asset = realpath($themeRoot.DIRECTORY_SEPARATOR.$normalised); abort_unless( $asset !== false && str_starts_with($asset, $themeRoot.DIRECTORY_SEPARATOR) && is_file($asset), 404 ); $mime = match ($extension) { 'css' => 'text/css; charset=UTF-8', 'js', 'mjs' => 'application/javascript; charset=UTF-8', 'svg' => 'image/svg+xml', 'json', 'map', 'webmanifest' => 'application/json', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'ttf' => 'font/ttf', 'otf' => 'font/otf', default => mime_content_type($asset) ?: 'application/octet-stream', }; return response()->file($asset, [ 'Content-Type' => $mime, 'Cache-Control' => app()->isProduction() ? 'public, max-age=31536000, immutable' : 'no-cache, private', 'X-Content-Type-Options' => 'nosniff', 'Content-Security-Policy' => "default-src 'none'; style-src 'unsafe-inline'", ]); } }