query('theme'); $path = $request->query('path'); try { $content = $editorService->readFile($theme, $path); // We need the full path to get the extension for the response $basePath = realpath(base_path('themes/' . $theme)); $fullPath = realpath($basePath . '/' . $path); return response()->json([ 'content' => $content, 'extension' => File::extension($fullPath) ]); } catch (Exception $e) { $statusCode = str_contains($e->getMessage(), 'Unauthorized') ? 403 : 404; return response()->json(['error' => $e->getMessage()], $statusCode); } } }