Add admin subdomain redirect for admin.myhoneydue.com

When ADMIN_HOST is set, redirects root "/" to "/admin/" so
admin.myhoneydue.com works without needing the /admin path suffix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-03-07 12:25:26 -06:00
parent 821a3e452f
commit 1fdc29af1c

View File

@@ -456,6 +456,19 @@ func setupAdminProxy(router *echo.Echo) {
adminURL = "http://127.0.0.1:3001"
}
// Admin subdomain (e.g. admin.myhoneydue.com) — redirect root to /admin/
adminHost := os.Getenv("ADMIN_HOST")
if adminHost != "" {
router.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if c.Request().Host == adminHost && c.Request().URL.Path == "/" {
return c.Redirect(http.StatusMovedPermanently, "/admin/")
}
return next(c)
}
})
}
target, err := url.Parse(adminURL)
if err != nil {
return