Trek_CN/server
Julien G. de6c0fb781
fix: prevent Invalid URL crash when APP_URL lacks a protocol (#972)
* fix: prevent Invalid URL crash when APP_URL lacks a protocol (issue #970)

- Add getMcpSafeUrl() to notifications.ts: wraps getAppUrl() and
  guarantees a result that satisfies the MCP SDK's checkIssuerUrl
  requirement (https:// or http://localhost). Non-HTTPS, non-localhost
  URLs fall back to http://localhost:{PORT} instead of propagating an
  "Issuer URL must be HTTPS" error.
- Switch app.ts, mcp/index.ts, mcp/oauthProvider.ts, and oauthService.ts
  to import getMcpSafeUrl instead of getAppUrl for all MCP resource URL
  construction, so a misconfigured APP_URL never crashes the metadata
  router initialisation.
- Restrict the SDK metadata router middleware to /.well-known/* paths
  only. Previously it was invoked on every request; in production the
  lazy getMetaRouter() init ran on GET / and threw "Invalid URL" when
  APP_URL had no scheme, returning 500 for every page load.
- Log a startup warning when APP_URL is set but not usable, and include
  the resolved App URL in the startup banner so operators can confirm
  the correct value at a glance.
- Update oauth.test.ts mock to target notifications.getMcpSafeUrl.

* fix: show getAppUrl in banner and add two separate APP_URL startup checks

- Banner now displays getAppUrl() (the resolved app URL) rather than
  getMcpSafeUrl() so operators see the actual configured value
- Two independent startup warnings after the banner when APP_URL is set:
  1. whether APP_URL is a valid URL (parseable by new URL())
  2. whether APP_URL is MCP-safe (https:// or http://localhost)
- Fix getMcpSafeUrl() fallback port to use Number(PORT) || 3001,
  consistent with how index.ts parses PORT

* fix: update oidc.ts to import getAppUrl from notifications
2026-05-07 13:49:39 +02:00
..
assets refactor: move airports.json out of server/data into server/assets 2026-04-18 02:02:09 +02:00
public v3.0.16 — bug fixes (#964) 2026-05-06 21:38:40 +02:00
scripts docs: add full wiki with 74 pages, assets, and CI workflow 2026-04-20 10:11:53 +02:00
src fix: prevent Invalid URL crash when APP_URL lacks a protocol (#972) 2026-05-07 13:49:39 +02:00
tests fix: prevent Invalid URL crash when APP_URL lacks a protocol (#972) 2026-05-07 13:49:39 +02:00
.env.example fix: add APP_VERSION fallback and HOST bind address env var (#952 #953) (#955) 2026-05-04 14:21:55 +02:00
package-lock.json chore: bump version to 3.0.16 [skip ci] 2026-05-06 19:38:58 +00:00
package.json chore: bump version to 3.0.16 [skip ci] 2026-05-06 19:38:58 +00:00
reset-admin.js Stabilize core: better-sqlite3, versioned migrations, graceful shutdown 2026-03-22 17:52:24 +01:00
tsconfig.json v3.0.16 — bug fixes (#964) 2026-05-06 21:38:40 +02:00
vitest.config.ts refactor(mcp): replace direct DB access with service layer calls 2026-04-04 18:12:53 +02:00