diff options
| author | diogo464 <[email protected]> | 2025-08-13 14:02:35 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-13 14:02:35 +0100 |
| commit | 86c0a412d2ed3fb22735e373d951e50ee24cdacd (patch) | |
| tree | 348472edcedf8cd0f8685da06dbca20a094f1c08 | |
| parent | 80b66131b793c7d3b9a5df9168906e29e296a057 (diff) | |
Fix SSR storage data fetching in drive pages
- Replace HTTP fetch with direct function import
- Remove environment-dependent URL construction
- Fix 'Failed to parse URL from /api/storage' error in production
- Import fetchStorageData directly from lib/storage
- Enable static rendering for /drive page
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
| -rw-r--r-- | frontend/app/drive/[...path]/page.tsx | 22 | ||||
| -rw-r--r-- | frontend/app/drive/page.tsx | 22 |
2 files changed, 2 insertions, 42 deletions
diff --git a/frontend/app/drive/[...path]/page.tsx b/frontend/app/drive/[...path]/page.tsx index bfb65ad..69db5c4 100644 --- a/frontend/app/drive/[...path]/page.tsx +++ b/frontend/app/drive/[...path]/page.tsx | |||
| @@ -1,26 +1,6 @@ | |||
| 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" | 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" |
| 2 | import { Drive_ls } from "@/lib/drive_server" | 2 | import { Drive_ls } from "@/lib/drive_server" |
| 3 | 3 | import { fetchStorageData } from "@/lib/storage" | |
| 4 | async function fetchStorageData() { | ||
| 5 | try { | ||
| 6 | const response = await fetch(`${process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3000' : ''}/api/storage`, { | ||
| 7 | cache: 'no-store' | ||
| 8 | }) | ||
| 9 | if (!response.ok) { | ||
| 10 | throw new Error('Failed to fetch storage data') | ||
| 11 | } | ||
| 12 | return await response.json() | ||
| 13 | } catch (error) { | ||
| 14 | console.error('Failed to fetch storage data:', error) | ||
| 15 | // Return zeros on error as requested | ||
| 16 | return { | ||
| 17 | activeDriveUsage: 0, | ||
| 18 | totalDiskCapacity: 0, | ||
| 19 | totalDiskUsed: 0, | ||
| 20 | availableDisk: 0 | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
| 24 | 4 | ||
| 25 | export default async function DriveDirectoryPage({ | 5 | export default async function DriveDirectoryPage({ |
| 26 | params, | 6 | params, |
diff --git a/frontend/app/drive/page.tsx b/frontend/app/drive/page.tsx index ea5846e..70bc943 100644 --- a/frontend/app/drive/page.tsx +++ b/frontend/app/drive/page.tsx | |||
| @@ -1,26 +1,6 @@ | |||
| 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" | 1 | import { DriveDirectoryView } from "@/components/drive/DriveDirectoryView" |
| 2 | import { Drive_ls } from "@/lib/drive_server" | 2 | import { Drive_ls } from "@/lib/drive_server" |
| 3 | 3 | import { fetchStorageData } from "@/lib/storage" | |
| 4 | async function fetchStorageData() { | ||
| 5 | try { | ||
| 6 | const response = await fetch(`${process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3000' : ''}/api/storage`, { | ||
| 7 | cache: 'no-store' | ||
| 8 | }) | ||
| 9 | if (!response.ok) { | ||
| 10 | throw new Error('Failed to fetch storage data') | ||
| 11 | } | ||
| 12 | return await response.json() | ||
| 13 | } catch (error) { | ||
| 14 | console.error('Failed to fetch storage data:', error) | ||
| 15 | // Return zeros on error as requested | ||
| 16 | return { | ||
| 17 | activeDriveUsage: 0, | ||
| 18 | totalDiskCapacity: 0, | ||
| 19 | totalDiskUsed: 0, | ||
| 20 | availableDisk: 0 | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
| 24 | 4 | ||
| 25 | export default async function DriveRootPage() { | 5 | export default async function DriveRootPage() { |
| 26 | const [files, storageData] = await Promise.all([ | 6 | const [files, storageData] = await Promise.all([ |
