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
|
configSaving.value = true
|
||||||
configSaveMsg.value = ''
|
configSaveMsg.value = ''
|
||||||
try {
|
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')
|
const res = await fetch('/api/v1/admin/config')
|
||||||
if (!res.ok) throw new Error(`Failed to load current config: HTTP ${res.status}`)
|
if (res.ok) {
|
||||||
const currentConfig = await res.json()
|
currentConfig = await res.json()
|
||||||
|
}
|
||||||
|
// If 404, just use empty currentConfig - we'll create a new file
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
|
|||||||
Reference in New Issue
Block a user