mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 00:40:47 +00:00
Fix cosmos explorer incorrect redirect
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func RegisterExplorerHandlers(router *gin.Engine) {
|
||||
explorer := router.Group("/_explorer")
|
||||
explorer := router.Group(config.Config.ExplorerBaseUrlLocation)
|
||||
{
|
||||
explorer.Use(func(ctx *gin.Context) {
|
||||
if ctx.Param("filepath") == "/config.json" {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user