fix: allow saving admin config when config file doesn't exist
- saveConfig no longer throws error when current config returns 404 - Creates new config file with current values if none exists - User can save config for the first time without errors
This commit is contained in:
@@ -1327,9 +1327,13 @@ async function saveConfig() {
|
||||
configSaving.value = true
|
||||
configSaveMsg.value = ''
|
||||
try {
|
||||
// Try to load current config, but don't fail if it doesn't exist
|
||||
let currentConfig: any = {}
|
||||
const res = await fetch('/api/v1/admin/config')
|
||||
if (!res.ok) throw new Error(`Failed to load current config: HTTP ${res.status}`)
|
||||
const currentConfig = await res.json()
|
||||
if (res.ok) {
|
||||
currentConfig = await res.json()
|
||||
}
|
||||
// If 404, just use empty currentConfig - we'll create a new file
|
||||
|
||||
const payload = {
|
||||
version: '1.0.0',
|
||||
|
||||
Reference in New Issue
Block a user