feat(setup): collect server base URL during first-run wizard

Add a Server URL field to the admin-account step of the setup wizard so
the public base URL (used for device sync, OPDS feed, and API endpoints)
is configured up front instead of requiring a later visit to admin
settings.

- setup.templ: base URL input on the admin step plus a summary entry
- setup.ts: default baseUrl to window.location.origin and persist it via
  PUT /system/config ({ base_url }) right after the admin account is
  created, with a non-fatal warning if the save fails
This commit is contained in:
2026-06-07 00:03:01 -04:00
parent f75d68bf66
commit 3170aa6b77
3 changed files with 34 additions and 4 deletions
+16 -3
View File
@@ -36,14 +36,13 @@ function initSetup(): void {
if (savedTheme && savedTheme !== "tokyo-night") {
applyTheme(savedTheme);
}
}
Alpine.data("setupWizard", () => ({
}Alpine.data("setupWizard", () => ({
currentStep: 1 as number,
loading: false as boolean,
errorMsg: "" as string,
admin: {
baseUrl: "",
email: "",
username: "",
password: "",
@@ -71,6 +70,7 @@ Alpine.data("setupWizard", () => ({
init() {
initSetup();
this.admin.baseUrl = window.location.origin;
setTimeout(() => {
initPasswordValidation();
}, 100);
@@ -128,6 +128,8 @@ Alpine.data("setupWizard", () => ({
setToken(data.token || data.access_token);
setRefreshToken(data.refresh_token);
await this.saveBaseUrl();
showToast("Admin account created successfully!", "success");
this.currentStep = 2;
} catch (err) {
@@ -137,6 +139,17 @@ Alpine.data("setupWizard", () => ({
}
},
async saveBaseUrl() {
if (!this.admin.baseUrl) return;
try {
await handleVoidResponse(
await apiPut("/system/config", { base_url: this.admin.baseUrl })
);
} catch {
showToast("Warning: could not save server URL. You can set it later in Admin Settings.", "warning");
}
},
async addLibrary() {
this.clearError();
this.loading = true;