Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: skip api error for static middleware (#941)
boojack40d25f7dcabc
diff --git a/server/common.go b/server/common.goindex 054fe6b70..1ac53c45e 100644--- a/server/common.go+++ b/server/common.go@@ -22,6 +22,11 @@ func DefaultGetRequestSkipper(c echo.Context) bool {return c.Request().Method == http.MethodGet}+func DefaultAPIRequestSkipper(c echo.Context) bool {+ path := c.Path()+ return common.HasPrefixes(path, "/api")+}+func (server *Server) DefaultAuthSkipper(c echo.Context) bool {ctx := c.Request().Context()path := c.Path()diff --git a/server/embed_frontend.go b/server/embed_frontend.goindex fa7ed59e1..7de421e00 100644--- a/server/embed_frontend.go+++ b/server/embed_frontend.go@@ -25,18 +25,19 @@ func embedFrontend(e *echo.Echo) {// Use echo static middleware to serve the built dist folder// refer: https://github.com/labstack/echo/blob/master/middleware/static.goe.Use(middleware.StaticWithConfig(middleware.StaticConfig{+ Skipper: DefaultAPIRequestSkipper,HTML5: true,Filesystem: getFileSystem("dist"),}))- g := e.Group("assets")- g.Use(func(next echo.HandlerFunc) echo.HandlerFunc {+ assetsGroup := e.Group("assets")+ assetsGroup.Use(func(next echo.HandlerFunc) echo.HandlerFunc {return func(c echo.Context) error {c.Response().Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")return next(c)}})- g.Use(middleware.StaticWithConfig(middleware.StaticConfig{+ assetsGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{HTML5: true,Filesystem: getFileSystem("dist/assets"),}))diff --git a/server/server.go b/server/server.goindex 62baacf98..6cbff9485 100644--- a/server/server.go+++ b/server/server.go@@ -56,9 +56,7 @@ func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {e.Use(middleware.Gzip())e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{- Skipper: func(c echo.Context) bool {- return s.DefaultAuthSkipper(c)- },+ Skipper: s.DefaultAuthSkipper,TokenLookup: "cookie:_csrf",}))@@ -73,7 +71,6 @@ func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {}))e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{- Skipper: middleware.DefaultSkipper,ErrorMessage: "Request timeout",Timeout: 30 * time.Second,}))