Skip to content

feat(security): enforce HTTPS for public/browser-facing URLs in production#283

Merged
NickLetts2 merged 3 commits into
mainfrom
copilot/fix-http-to-https-config
May 15, 2026
Merged

feat(security): enforce HTTPS for public/browser-facing URLs in production#283
NickLetts2 merged 3 commits into
mainfrom
copilot/fix-http-to-https-config

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

SonarCloud S5332 flagged HTTP URLs across several API client files. After classification, all flagged defaults (http://core-api:5000, http://billing-service:8000, etc.) are server-only Docker-network URLs — safe as HTTP. The two genuinely browser-facing variables (NEXT_PUBLIC_API_URL, PUBLIC_APP_URL) had no production HTTPS enforcement.

Classification

URL Verdict
http://core-api:5000, http://*-service:8000 Server-only Docker URLs — not browser-reachable
http://app-frontend:3000 (marketing-site internalAppUrl) Server-only Docker URL
http://127.0.0.1:41017 (billing.ts) Localhost, E2E-only (PLAYWRIGHT_E2E=1 guard)
NEXT_PUBLIC_API_URL, PUBLIC_APP_URL Browser-facing — remediated

Changes

  • src/lib/url-validation.ts (both apps) — requireHttpsInProduction(name, value) helper: throws in production if the value starts with http://, no-ops in dev/test.
export function requireHttpsInProduction(name: string, value: string): string {
  if (process.env.NODE_ENV === 'production' && value.startsWith('http://')) {
    throw new Error(`${name} must use HTTPS in production. ...`);
  }
  return value;
}
  • apps/app-frontend/next.config.ts — calls requireHttpsInProduction('NEXT_PUBLIC_API_URL', ...) at startup inside the existing production env-var validation block (fail-closed before the server accepts traffic).

  • apps/marketing-site/src/config.ts — wraps appUrl with the helper; internalAppUrl is intentionally left unvalidated (Docker-internal only). The marketing-site variant also checks import.meta.env.PROD because Astro sets that flag during SSG builds before NODE_ENV propagates.

  • 18 unit tests (9 per app) covering: throws on http:// in production, passes on https:// in production, passes on http://localhost in dev/test.

Copilot AI and others added 2 commits May 15, 2026 20:12
…ction

- Add requireHttpsInProduction helper to app-frontend and marketing-site
- Validate NEXT_PUBLIC_API_URL uses HTTPS in production via next.config.ts
- Validate PUBLIC_APP_URL uses HTTPS in production via marketing-site config.ts
- Add unit tests for both URL validation helpers (18 tests total)

All server-only Docker network URLs (http://core-api:5000, etc.) are
correctly classified as safe — they communicate over private Docker
networks and never reach a browser.

Closes: S5332 SonarCloud hotspots for public-facing URLs"

Agent-Logs-Url: https://github.com/NickLetts2/Curvit/sessions/d94c2413-0222-438c-8feb-754db10cd98d

Co-authored-by: NickLetts2 <90337962+NickLetts2@users.noreply.github.com>
…ocument Astro dual-detection rationale

Agent-Logs-Url: https://github.com/NickLetts2/Curvit/sessions/d94c2413-0222-438c-8feb-754db10cd98d

Co-authored-by: NickLetts2 <90337962+NickLetts2@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix security hotspots by replacing HTTP with HTTPS feat(security): enforce HTTPS for public/browser-facing URLs in production May 15, 2026
Copilot AI requested a review from NickLetts2 May 15, 2026 20:16
@NickLetts2 NickLetts2 marked this pull request as ready for review May 15, 2026 20:35
Copilot AI review requested due to automatic review settings May 15, 2026 20:35
@NickLetts2 NickLetts2 merged commit fb3a52e into main May 15, 2026
6 of 7 checks passed
Copilot AI review requested due to automatic review settings May 15, 2026 20:57
NickLetts2 added a commit that referenced this pull request Jun 1, 2026
feat(security): enforce HTTPS for public/browser-facing URLs in production
@NickLetts2 NickLetts2 deleted the copilot/fix-http-to-https-config branch June 2, 2026 09:46
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.

Security Hotspots: Replace public/browser-facing HTTP fallbacks with HTTPS or fail-closed config

2 participants