v0.1.5 Fix bug with host routing

This commit is contained in:
Yann Stepienik 2023-04-01 17:49:54 +01:00
parent 50498b406c
commit 543204a87c
2 changed files with 5 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -182,17 +182,6 @@ func StartServer() {
router.Use(middleware.Recoverer)
router.Use(middleware.Logger)
router.Use(utils.SetSecurityHeaders)
router.Methods("GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"OPTIONS",
"HEAD",
).Host(config.Hostname).Subrouter().HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/ui", http.StatusMovedPermanently)
}))
srapi := router.PathPrefix("/cosmos").Subrouter()
@ -235,6 +224,10 @@ func StartServer() {
router.PathPrefix("/ui").Handler(http.StripPrefix("/ui", fs))
router = proxy.BuildFromConfig(router, config.ProxyConfig)
router.HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/ui", http.StatusMovedPermanently)
}))
if ((config.HTTPSCertificateMode == utils.HTTPSCertModeList["SELFSIGNED"] || config.HTTPSCertificateMode == utils.HTTPSCertModeList["PROVIDED"]) &&
tlsCert != "" && tlsKey != "") || (config.HTTPSCertificateMode == utils.HTTPSCertModeList["LETSENCRYPT"]) {