Three bugs fixed: 1. Schema seeded base_url with fake placeholder 'bookhoard.example.com'. Removed seed; startup now seeds from BASE_URL env var only if DB row is empty (admin changes persist across restarts). One-time UPDATE clears the placeholder in existing installs. 2. config.GetBaseURL() had a broken type assertion (local SystemConfigRow vs database.SystemConfig) that always failed, returning . Admin panel showed env var fallback instead of actual DB value. Fixed with a function-type getter that properly wraps the DB query. 3. OPDS handler read base_url only from DB with no fallback. When DB had the placeholder, all feed links pointed to an unreachable domain, breaking KOReader search/download. Added deriveBaseURL() helper that falls back to the request Host/scheme when DB value is empty. Setup gate improvements: - isSetupComplete now requires both admin user AND non-empty base_url - Setup middleware no longer exempts all /api/ routes; only allows /api/auth/register, /api/auth/login, /api/system/config before setup is complete. All other API routes get 503. - Cache invalidated when base_url is saved via admin settings Dev workflow: - New bruno/NewDevDBSetup/SetBaseUrl.yml for dev DB setup - NewDB.sh runs SetBaseUrl between RegisterUser and CreateEbookLibrary
39 lines
763 B
YAML
39 lines
763 B
YAML
info:
|
|
name: SetBaseUrl
|
|
type: http
|
|
seq: 3
|
|
|
|
http:
|
|
method: PUT
|
|
url: '{{base_url}}/api/system/config'
|
|
auth: inherit
|
|
body:
|
|
type: json
|
|
jsonBody: |-
|
|
{
|
|
"base_url": "http://localhost:8765"
|
|
}
|
|
headers:
|
|
- key: Authorization
|
|
value: Bearer {{token}}
|
|
- key: Content-Type
|
|
value: application/json
|
|
|
|
settings:
|
|
encodeUrl: true
|
|
timeout: 0
|
|
followRedirects: true
|
|
maxRedirects: 5
|
|
|
|
docs: |-
|
|
## Set Base URL
|
|
|
|
Configures the server's base_url during initial dev database setup.
|
|
|
|
Must be run after RegisterUser (which provides the auth token) and before
|
|
any library/device creation (which require setup to be complete).
|
|
|
|
**Method:** PUT
|
|
**Endpoint:** /api/system/config
|
|
**Auth:** Bearer token (from RegisterUser)
|