fix cors
This commit is contained in:
4
main.go
4
main.go
@@ -35,6 +35,10 @@ func main() {
|
||||
|
||||
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)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/labstack/echo-jwt/v4"
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,10 @@ var JWT_MW = echojwt.WithConfig(echojwt.Config{
|
||||
if strings.Contains(c.Path(), "auth") || c.Path() == "/api/health" {
|
||||
return true
|
||||
}
|
||||
|
||||
if c.Request().Method == http.MethodOptions {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
SuccessHandler: func(c echo.Context) {
|
||||
|
||||
Reference in New Issue
Block a user