config: simplify to single base_url with computed paths

Refactor configuration to use one source of truth for base URL

- Add GetBaseURL() to config package: queries system_config table first,
  falls back to BASE_URL env var
- Update SidecarHandler to accept config and use single base_url
- Compute opds/api paths from base_url instead of storing separately:
  - OPDS: base_url + /opds
  - API: base_url + /api
  - Device Sync: base_url + /api/sync
- Simplify OPDSHandler.getBaseURLs() to compute opds path
- Remove need for separate opds_base_url and api_base_url columns

Previously the system stored three separate URL config values that were
usually the same domain with different paths. Now store only base_url
and compute the paths, eliminating configuration redundancy.
This commit is contained in:
2026-03-11 16:42:21 -04:00
parent c1b664dbe5
commit 5a61d9e321
3 changed files with 101 additions and 24 deletions
+3 -7
View File
@@ -38,19 +38,15 @@ func NewOPDSHandler(db *database.Queries, libraryService *services.LibraryServic
}
}
// Helper function to get base URLs from system config
// Helper function to get base URL from system config
func (h *OPDSHandler) getBaseURLs(c *echo.Context) (string, string, error) {
baseURL, err := h.db.GetSystemConfig(c.Request().Context(), "base_url")
if err != nil {
return "", "", fmt.Errorf("failed to get base_url from config: %w", err)
}
opdsBaseURL, err := h.db.GetSystemConfig(c.Request().Context(), "opds_base_url")
if err != nil {
return "", "", fmt.Errorf("failed to get opds_base_url from config: %w", err)
}
return baseURL.Value, opdsBaseURL.Value, nil
opdsBaseURL := baseURL.Value + "/opds"
return baseURL.Value, opdsBaseURL, nil
}
// GetDeviceCatalog returns the OPDS catalog feed for a device