From 4089a5fccc64e7f792889ebfc430c5beda82b7fe Mon Sep 17 00:00:00 2001 From: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com> Date: Sun, 25 Sep 2022 02:06:32 +0200 Subject: [PATCH] Fix JSON.parse console error (#2943) --- internal/api/server.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/api/server.go b/internal/api/server.go index 853044da9..93189afcc 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -181,18 +181,16 @@ func Start() error { }) r.HandleFunc("/customlocales", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - if !c.GetCustomLocalesEnabled() { - return + if c.GetCustomLocalesEnabled() { + // search for custom-locales.json in current directory, then $HOME/.stash + fn := c.GetCustomLocalesPath() + exists, _ := fsutil.FileExists(fn) + if exists { + http.ServeFile(w, r, fn) + return + } } - - // search for custom-locales.json in current directory, then $HOME/.stash - fn := c.GetCustomLocalesPath() - exists, _ := fsutil.FileExists(fn) - if !exists { - return - } - - http.ServeFile(w, r, fn) + _, _ = w.Write([]byte("{}")) }) r.HandleFunc("/login*", func(w http.ResponseWriter, r *http.Request) {