From 31fcc2863d97c0bb104bc895c206e0e6ae0127bf Mon Sep 17 00:00:00 2001 From: kandrusyak Date: Tue, 25 Jul 2023 00:57:36 +0300 Subject: [PATCH] fix cors --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 8b58e7a..db7a0e6 100644 --- a/main.go +++ b/main.go @@ -31,14 +31,19 @@ func main() { e.Use(mw.TokenFromCookies) e.Use(mw.JWT_MW) + e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + if c.Request().Method == http.MethodOptions { + return c.NoContent(http.StatusOK) + } + return next(c) + } + }) + e.Pre(middleware.RemoveTrailingSlash()) mainGroup := e.Group("/api") - mainGroup.OPTIONS("/*", func(c echo.Context) error { - return c.NoContent(http.StatusOK) - }) - // Routes mainGroup.GET("/*", checkAuth) mainGroup.GET("/health", handler.Health)