Skip to content

feat: configurable gateway public_url for settings endpoints (v0.6.3) - #96

Merged
argszero merged 1 commit into
mainfrom
feat/public-url-config
Aug 19, 2026
Merged

argszero merged 1 commit into
mainfrom
feat/public-url-config

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Settings page '接入方式' endpoint URLs were hardcoded to https://gateway.aitokenpool.local/v1 and /anthropic. This PR makes them config-driven (host rant 2026-08-19T20:37:37, project: aitokenpool).

Changes:

  • config: [server].public_url field (default http://localhost:8080, decoupled from the listen addr); documented in config/config.example.toml + README
  • backend: new GET /api/config{"public_url": "..."} (unauthenticated, non-sensitive; reusable for future frontend config)
  • frontend (ui/js/app.js): endpoint card built at render time as {public_url}/v1 and {public_url}/anthropic; falls back to location.origin when config is unreachable (same-origin deploys stay correct); Live.publicUrl loaded during session init
  • tests: server_public_url_defaults_to_localhost (config) + config_returns_public_url (route); full suite 113/113 green

Related Issue

Rant: 2026-08-19T20:37:37.082472+08:00 (接入方式 URL 配置化 — 不再硬编码域名)

Tests

  • cargo test — 113/113 pass (2 new)
  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • node --check app.js / i18n.js
  • live smoke: /api/config → configured value, /healthz v0.6.3, index 200

… endpoint card (v0.6.3)

Rant 2026-08-19T20:37:37: settings '接入方式' endpoint URLs were
hardcoded (https://gateway.aitokenpool.local/v1|/anthropic).

- config [server].public_url (default http://localhost:8080, decoupled
  from listen addr); documented in config.example.toml + README
- GET /api/config returns {public_url} (unauthenticated, non-sensitive)
- frontend builds endpoints as {public_url}/v1 and {public_url}/anthropic
  at render time; falls back to location.origin when config unreachable
- tests: config.rs default assertion + route test; 113/113 pass
@argszero
argszero merged commit e74f7fc into main Aug 19, 2026
1 check passed
argszero added a commit that referenced this pull request Sep 13, 2026
`ui/index.html` carries every `data-i18n` string twice: once as the
element's static text (the fallback) and once in the pack
(`ui/js/i18n.js`). `applyStatic()` overwrites the element with the pack
value on DOMContentLoaded, so the fallback is normally invisible — but it
is still a second source of truth, and two of its entries state things
that are no longer true:

- `ops.hours.sub`: 「按小时用量记录 · 本地时区」. The backend buckets
  `today_hours` by UTC (`src/routes/ops.rs:5`, `:115`) and the pack says
  「服务端 UTC 时区」. Introduced already-contradictory in 09e4121 (#157).
- `settings.ep.note`: 「部署后替换为你的网关域名(原型占位说明)」 — a
  verbatim copy of the prototype (docs/prototype/aitokenpool-console.html:705)
  including the 「原型占位说明」 marker. The endpoint card became
  config-driven in e74f7fc (#96) and the pack was updated then; only the
  static fallback was left behind.

Both static strings are now identical to their pack entry. Data-only
(HTML text), zero behaviour change: the rendered UI already showed the
pack value, so no user-visible output changes. No i18n key added or
removed (786 keys before and after), no JS/CSS touched, so no cache-bust.

The remaining fallback divergences are deliberate older wording (which is
the fallback's purpose) and are left alone; only false/stale text is a
defect.

Co-authored-by: argszero <argszero@argszerodeMac-mini.local>
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