Skip to content

refactor(frontend): deduplicate API base URL configuration#32

Open
abhiram-tekulapalli wants to merge 1 commit into
DemocratiseResearch:mainfrom
abhiram-tekulapalli:chore/dedupe-api-base-url
Open

refactor(frontend): deduplicate API base URL configuration#32
abhiram-tekulapalli wants to merge 1 commit into
DemocratiseResearch:mainfrom
abhiram-tekulapalli:chore/dedupe-api-base-url

Conversation

@abhiram-tekulapalli

@abhiram-tekulapalli abhiram-tekulapalli commented Jul 20, 2026

Copy link
Copy Markdown

Refactor frontend authentication pages to use shared API base URL

Reviewer: @handle

Type: [ ] Feature [ ] Bug Fix [x] Refactor [ ] Docs/Config [ ] Hotfix

Breaking change? [ ] Yes [x] No


Summary

This PR removes duplicated BASE_URL declarations across the frontend authentication pages and replaces them with the shared BASE_URL exported from frontend/lib/api/client.ts.

By centralizing the API base URL configuration, this refactor reduces code duplication, improves maintainability, and ensures future API endpoint changes only need to be made in one place. No functional behavior is intended to change.


Rough Example / Context

Before

const BASE_URL =
  process.env.NEXT_PUBLIC_GATEWAY ??
  process.env.NEXT_PUBLIC_API_URL ??
  "http://localhost:8080";

The same configuration was duplicated across multiple authentication pages.

After

import { BASE_URL } from "@/lib/api/client";

All authentication pages now use the shared configuration from a single source.


How to test locally

git checkout chore/dedupe-api-base-url

npm install

npm run lint

npx tsc --noEmit

npm run build

Verify that:

  • Login page builds successfully.
  • Signup page builds successfully.
  • Forgot Password page builds successfully.
  • Reset Password page builds successfully.
  • Authentication requests continue using the shared BASE_URL.

Checklist

Tick only what you've actually done.

Always

  • Read through my own diff on GitHub before raising this
  • No commented-out code, console.log, or debug artifacts left in
  • No hardcoded URLs, tokens, or env-specific strings — use .env
  • If anything changed in how the project runs, README is updated

Frontend

  • Searched the codebase — this component doesn't already render somewhere else
  • Tested error state, empty state, and loading state — not just the happy path
  • Screenshots below for every visible change

Backend / API

  • Auth is enforced on new endpoints — no unprotected routes
  • Inputs are validated — no raw user data hitting the DB or external services
  • Errors return proper HTTP status codes
  • No sensitive data in responses — no stack traces, internal IDs, raw DB errors
  • Rate limiting considered for any user-facing or polling-heavy endpoint
  • Frontend handles backend being unreachable — no blank screens or silent failures

Docs / Config

  • New or changed env vars listed below
  • Nothing sensitive committed — keys, tokens, internal URLs

Screenshots (required for any UI change)

N/A – This PR does not introduce any visible UI changes.


Env vars added or changed (if any)

None.


AI pre-review

  • Done

What it flagged: N/A

What I fixed: N/A

What I pushed back on (and why): N/A


Anything the reviewer should know

This is a refactoring-only change. No functional behavior is intended to change.

Validation completed:

  • npm run lint (existing repository warnings only; no new lint errors)
  • npx tsc --noEmit
  • npm run build

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.

1 participant