Skip to content

Conversation

@oliveirara
Copy link
Contributor

@oliveirara oliveirara commented Sep 8, 2025

  • use relative paths for data files to work with base URL
  • improve error handling for fetch requests
  • add documentation for deployment to GitHub Pages
  • explain how to configure base path for static JSON and assets
  • add troubleshooting steps for common JSON parse error

Summary by CodeRabbit

• Documentation
• Added detailed GitHub Pages deployment guide, including base path setup, build command example, verification steps, and notes about data file placement and trailing slash requirements.

• Bug Fixes
• Fixed script and data path resolution for subpath hosting to prevent 404s and JSON parse errors.

• Refactor
• Centralized data loading with environment-driven base URL, consistent relative paths, no-cache fetches, and clearer error reporting for failed requests or invalid JSON.

- use relative paths for data files to work with base URL
- improve error handling for fetch requests
- add documentation for deployment to GitHub Pages
- explain how to configure base path for static JSON and assets
- add troubleshooting steps for common JSON parse error
@oliveirara oliveirara self-assigned this Sep 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Added deployment guidance for GitHub Pages with BASE_PATH/BASE_URL usage, switched index.html module script to a relative path, and refactored data loading in api.ts to use a centralized BASE_URL-driven fetchJson helper with enhanced error handling and URL construction for JSON assets and cutout URLs.

Changes

Cohort / File(s) Summary of Changes
Docs: GitHub Pages deployment
dashboard/README.md
Added a Deployment section detailing BASE_PATH usage, build example, gh-pages publishing, BASE_URL-based data loading, and verification steps.
HTML entry point path resolution
dashboard/index.html
Changed module script src from /src/main.tsx to src/main.tsx to resolve relative to the HTML file.
API data loading refactor
dashboard/src/api.ts
Introduced BASE_URL, buildDataUrl, and fetchJson with improved error diagnostics and no-cache. Updated loaders (database, consolidated, dictionary, cutouts) to use fetchJson. Added RAW_ENDPOINT constant for cutout URL construction. Removed async keywords from loader declarations while retaining Promise return types.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User Browser
  participant A as App (Dashboard)
  participant L as Data Loader (fetchJson)
  participant S as Static Host (GitHub Pages)

  Note over A,L: BASE_URL taken from import.meta.env.BASE_URL

  U->>A: Open dashboard
  A->>L: loadDatabase()
  activate L
  L->>L: buildDataUrl("database.json")
  L->>S: GET <BASE_URL>data/database.json (no-cache)
  alt 200 OK JSON
    S-->>L: JSON body
    L-->>A: Parsed DataRecord[]
  else Error/HTML/404
    S-->>L: Error or HTML body
    L-->>A: Reject with status, URL, snippet
  end
  deactivate L

  A->>L: loadCutouts()
  L->>S: GET <BASE_URL>data/cutouts.json
  S-->>L: JSON or error
  L-->>A: Parsed CutoutRecord[] or error

  Note over A: Other loaders (dictionary, consolidated) follow same flow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit taps deploy with glee,
“BASE_URL set? Then data’s free!”
From burrowed docs to paths made right,
No 404s to spoil the night.
With fetchJson nibbling byte by byte,
The dashboard hops—assets in sight! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdea387 and 6216139.

📒 Files selected for processing (3)
  • dashboard/README.md (1 hunks)
  • dashboard/index.html (1 hunks)
  • dashboard/src/api.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fix-paths

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oliveirara oliveirara merged commit 8f5bc93 into main Sep 8, 2025
0 of 2 checks passed
@oliveirara oliveirara deleted the feat/fix-paths branch September 8, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants