Skip to content

feat(settings): add optional Open-Meteo commercial API key#8

Merged
Flowm merged 1 commit into
mainfrom
claude/epic-wilson-991a95
Jun 25, 2026
Merged

feat(settings): add optional Open-Meteo commercial API key#8
Flowm merged 1 commit into
mainfrom
claude/epic-wilson-991a95

Conversation

@Flowm

@Flowm Flowm commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an optional Open-Meteo API key field in Settings. When a key is set, every open-meteo request — forecast, single-runs, archive, and geocoding — routes through the paid customer-*.open-meteo.com commercial endpoints with an apikey query param. With no key, the app stays on the free tier unchanged.

  • New buildOpenMeteoUrl() helper (src/api/openMeteo.ts) swaps the host to its customer- twin and appends the key; all four API clients route through it.
  • The key persists to localStorage (meteocompare:openmeteo:api-key) and is wired as a fetch dependency in useForecast/useVerification, so toggling it refetches the current view.
  • Service-worker cache routes updated to match the customer- hosts too.
  • Settings UI: a masked input plus a Clear button that empties the key.

Test plan

  • npm run lint, npm run type-check, npm test (147 tests) — all green.
  • New unit tests in src/api/openMeteo.test.ts cover the host-swap mapping and whitespace-key handling.
  • Verified in-browser: with a key set, forecast + geocoding requests hit customer-*.open-meteo.com?...&apikey=...; Clear reverts to the free hosts.

🤖 Generated with Claude Code

A key entered in Settings is stored in localStorage and routes every
open-meteo request (forecast, single-runs, archive, geocoding) through
the paid customer-*.open-meteo.com hosts with an apikey param; with no
key the app stays on the free tier unchanged.

The key is wired in as a fetch dependency so toggling it refetches the
current view, the service-worker cache routes match the customer hosts
too, and a Clear button removes it.

Assisted-by: ClaudeCode:claude-opus-4-8
@github-actions

Copy link
Copy Markdown

⛅ Preview deployment

This PR is live at https://preview-b00eed90-meteocompare.frcy.workers.dev

Commit b00eed90 — reproduce locally with npm run deploy:preview.

@Flowm
Flowm merged commit eceb3bb into main Jun 25, 2026
4 checks passed
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