Skip to content

[Frontend] Consolidate four different NEXT_PUBLIC_API_URL fallbacks (mix of /v1 and root) #622

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

Four places in the frontend define API_BASE_URL independently, with two different fallback shapes — some with /v1 and some without. This is the source of subtle bugs (e.g. issue #455 with the settings page calling ${baseWithV1}/health and getting /v1/health which doesn't exist).

Verified locations:

  • frontend/src/app/streams/[id]/page.tsx:46... || \"http://localhost:3001/v1\"
  • frontend/src/app/settings/page.tsx:19 (named INDEXER_URL) → ... || \"http://localhost:3001/v1\"
  • frontend/src/app/activity/page.tsx:13-15... || \"http://localhost:3001\" (no /v1)
  • frontend/src/components/TransactionTracker.tsx:59... || \"http://localhost:3001/v1\"
  • frontend/src/lib/api/_shared.ts:1 (canonical) → \"http://localhost:3001\" (no /v1) via getApiBaseUrl()

Some of these then concatenate /v1/streams/... directly, breaking depending on whether the env var ends in /v1.

Acceptance criteria

  • Make every fetch use the shared helper in frontend/src/lib/api/_shared.ts (extend if needed) so there's exactly one place that knows the base URL shape
  • All hardcoded fallback strings get removed from the four files above
  • Behaviour identical whether NEXT_PUBLIC_API_URL is set with or without trailing /v1

Files to touch

  • frontend/src/app/streams/[id]/page.tsx
  • frontend/src/app/settings/page.tsx
  • frontend/src/app/activity/page.tsx
  • frontend/src/components/TransactionTracker.tsx
  • frontend/src/lib/api/_shared.ts

Out of scope

  • Reworking the SSE event subscribe URL

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendFrontend related tasksgood first issueGood for newcomersrefactorRefactoring existing code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions