From 085806d1b2b5a23d4bc355e06391c763b38ee033 Mon Sep 17 00:00:00 2001 From: m1k1o Date: Wed, 10 Mar 2021 22:08:04 +0100 Subject: [PATCH] local default URI for client. --- client/vue.config.js | 1 + server/internal/http/http.go | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/client/vue.config.js b/client/vue.config.js index 2ade23d..b0da92b 100644 --- a/client/vue.config.js +++ b/client/vue.config.js @@ -11,6 +11,7 @@ module.exports = { }, }, }, + publicPath: './', configureWebpack: { resolve: { alias: { diff --git a/server/internal/http/http.go b/server/internal/http/http.go index e8cec82..d1294d3 100644 --- a/server/internal/http/http.go +++ b/server/internal/http/http.go @@ -10,7 +10,6 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "n.eko.moe/neko/internal/http/endpoint" "n.eko.moe/neko/internal/http/middleware" "n.eko.moe/neko/internal/types" "n.eko.moe/neko/internal/types/config" @@ -37,20 +36,14 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server { fs := http.FileServer(http.Dir(conf.Static)) router.Get("/*", func(w http.ResponseWriter, r *http.Request) { - if _, err := os.Stat(conf.Static + r.RequestURI); os.IsNotExist(err) { - http.StripPrefix(r.RequestURI, fs).ServeHTTP(w, r) - } else { + if _, err := os.Stat(conf.Static + r.RequestURI); !os.IsNotExist(err) { fs.ServeHTTP(w, r) + } else { + w.WriteHeader(http.StatusNotFound) + fmt.Fprint(w, "404 page not found") } }) - router.NotFound(endpoint.Handle(func(w http.ResponseWriter, r *http.Request) error { - return &endpoint.HandlerError{ - Status: http.StatusNotFound, - Message: fmt.Sprintf("file '%s' is not found", r.RequestURI), - } - })) - server := &http.Server{ Addr: conf.Bind, Handler: router,