diff --git a/assets/js/views/Issue.vue b/assets/js/views/Issue.vue index 8a22a67dc..9d2af5208 100644 --- a/assets/js/views/Issue.vue +++ b/assets/js/views/Issue.vue @@ -143,10 +143,10 @@ @@ -427,13 +427,21 @@ export default defineComponent({ try { const response = await api.get("config/evcc.yaml", { responseType: "text", + validateStatus: (code) => [200, 404].includes(code), }); + + // Handle 404 silently when evcc.yaml doesn't exist + if (response.status === 404) { + this.sections.yamlConfig.content = "no yaml configuration"; + return; + } + // Remove empty lines from config this.sections.yamlConfig.content = response.data .split("\n") .filter((line: string) => line.trim() !== "") .join("\n"); - } catch (error) { + } catch (error: any) { console.error("Failed to fetch config:", error); this.sections.yamlConfig.content = "Failed to load configuration"; } diff --git a/cmd/root.go b/cmd/root.go index f9d39501b..382f41fd2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -294,7 +294,7 @@ func runRoot(cmd *cobra.Command, args []string) { // publish system infos valueChan <- util.Param{Key: keys.Version, Val: util.FormattedVersion()} - valueChan <- util.Param{Key: keys.Config, Val: cfgFile} + valueChan <- util.Param{Key: keys.Config, Val: viper.ConfigFileUsed()} valueChan <- util.Param{Key: keys.Database, Val: db.FilePath} // run shutdown functions on stop @@ -343,7 +343,7 @@ func runRoot(cmd *cobra.Command, args []string) { log.INFO.Println("evcc was stopped by user. OS should restart the service. Or restart manually.") err = errors.New("restart required") // https://gokrazy.org/development/process-interface/ once.Do(func() { close(stopC) }) // signal loop to end - }, cfgFile) + }, viper.ConfigFileUsed()) // show and check version, reduce api load during development if util.Version != util.DevVersion {