Fix cosmos explorer incorrect redirect

This commit is contained in:
Pijus Kamandulis
2024-11-14 18:42:17 +02:00
parent 2834f3f641
commit c7d01b4593
6 changed files with 22 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ func Authentication() gin.HandlerFunc {
return func(c *gin.Context) {
requestUrl := c.Request.URL.String()
if config.Config.DisableAuth ||
strings.HasPrefix(requestUrl, "/_explorer") ||
strings.HasPrefix(requestUrl, config.Config.ExplorerBaseUrlLocation) ||
strings.HasPrefix(requestUrl, "/cosmium") {
return
}

View File

@@ -1,13 +1,16 @@
package middleware
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/pikami/cosmium/api/config"
)
func StripTrailingSlashes(r *gin.Engine) gin.HandlerFunc {
return func(c *gin.Context) {
path := c.Request.URL.Path
if len(path) > 1 && path[len(path)-1] == '/' {
if len(path) > 1 && path[len(path)-1] == '/' && !strings.Contains(path, config.Config.ExplorerBaseUrlLocation) {
c.Request.URL.Path = path[:len(path)-1]
r.HandleContext(c)
c.Abort()