diff --git a/logmessages/logmessages.go b/logmessages/logmessages.go index 160ce3b..41fa765 100644 --- a/logmessages/logmessages.go +++ b/logmessages/logmessages.go @@ -212,6 +212,7 @@ const ( FailedInitProxy = "Failed to initialize proxy @ \"%s\": %v\nStartup will pause for a bit to grab your attention." NoURLSuffix = `Warning: Given "jfa_url"/"External jfa-go URL" value does not include "url_base" value!` BadURLBase = `Warning: Given reverse proxy subfolder "%s" may conflict with the applications subpaths.` + RouteCollision = `Route Collision! Given reverse proxy subfolder "%s" or "URL Paths" settings likely conflict with the applications subpaths. Culprit: %v` NoExternalHost = `No "External jfa-go URL" provided, set one in Settings > General.` LoginWontSave = ` Your login won't save until you do.` SubpathBlockMessage = `URLs: Root subfolder = "%s", Admin = "%s", My Account = "%s", Invite forms = "%s"` diff --git a/router.go b/router.go index 2acb221..31df88b 100644 --- a/router.go +++ b/router.go @@ -114,6 +114,13 @@ func (app *appContext) loadRoutes(router *gin.Engine) { userPageEnabled := app.config.Section("user_page").Key("enabled").MustBool(true) && app.config.Section("ui").Key("jellyfin_login").MustBool(true) + // Route collision may occur when reverse proxy subfolder is the same as a pseudo-path (e.g. /accounts, /activity...). For non-obvious ones, recover from the panic. + defer func() { + if r := recover(); r != nil { + app.err.Fatalf(lm.RouteCollision, PAGES.Base, r) + } + }() + for _, p := range routePrefixes { router.GET(p+"/lang/:page", app.GetLanguages) router.Use(serveTaggedStatic(p+"/", app.webFS)) @@ -126,7 +133,10 @@ func (app *appContext) loadRoutes(router *gin.Engine) { } } - router.GET(p+PAGES.Admin+"/accounts", app.AdminPage) + // Handle the obvious collision of /accounts + if p != "" || PAGES.Admin != "" { + router.GET(p+PAGES.Admin+"/accounts", app.AdminPage) + } router.GET(p+PAGES.Admin+"/settings", app.AdminPage) router.GET(p+PAGES.Admin+"/activity", app.AdminPage) router.GET(p+PAGES.Admin+"/accounts/user/:userID", app.AdminPage)