diff --git a/public/init.js b/public/init.js index a49a8441..670ad39c 100644 --- a/public/init.js +++ b/public/init.js @@ -125,8 +125,8 @@ function fetchPhrases() { (() => { runInitHook("pre_iife"); let loggedIn = document.head.querySelector("[property='x-loggedin']").content; - - fetch("/api/me/") + if(loggedIn) { + fetch("/api/me/") .then((resp) => resp.json()) .then((data) => { console.log("loaded me endpoint data"); @@ -134,13 +134,15 @@ function fetchPhrases() { me = data; runInitHook("pre_init"); }); - - if(loggedIn) { + let toLoad = 1; loadScript("template_topics_topic.js", () => { console.log("Loaded template_topics_topic.js"); toLoad--; if(toLoad===0) fetchPhrases(); }); + } else { + me = {User:{ID:0,Session:""},Site:{"MaxRequestSize":0}}; + runInitHook("pre_init"); } })(); \ No newline at end of file diff --git a/routes/misc.go b/routes/misc.go index 8e3d8871..3d602dec 100644 --- a/routes/misc.go +++ b/routes/misc.go @@ -27,7 +27,7 @@ func StaticFile(w http.ResponseWriter, r *http.Request) { h := w.Header() // Surely, there's a more efficient way of doing this? - t, err := time.Parse(http.TimeFormat, h.Get("If-Modified-Since")) + t, err := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")) if err == nil && file.Info.ModTime().Before(t.Add(1*time.Second)) { w.WriteHeader(http.StatusNotModified) return @@ -36,7 +36,8 @@ func StaticFile(w http.ResponseWriter, r *http.Request) { h.Set("Content-Type", file.Mimetype) h.Set("Cache-Control", cacheControlMaxAge) //Cache-Control: max-age=31536000 h.Set("Vary", "Accept-Encoding") - if strings.Contains(h.Get("Accept-Encoding"), "gzip") { + + if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { h.Set("Content-Encoding", "gzip") h.Set("Content-Length", strconv.FormatInt(file.GzipLength, 10)) io.Copy(w, bytes.NewReader(file.GzipData)) // Use w.Write instead?