diff --git a/api/router.go b/api/router.go
index 940c839..f270cd4 100644
--- a/api/router.go
+++ b/api/router.go
@@ -10,6 +10,11 @@ import (
func routesServe() error {
router := mux.NewRouter()
+ subdir := pathStrip(os.Getenv("ORIGIN"))
+ if subdir != "" {
+ router = router.PathPrefix(subdir).Subrouter()
+ }
+
if err := apiRouterInit(router); err != nil {
return err
}
diff --git a/api/router_static.go b/api/router_static.go
index 982b9d4..5f0da5a 100644
--- a/api/router_static.go
+++ b/api/router_static.go
@@ -13,7 +13,7 @@ import (
)
func redirectLogin(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, "/login", 301)
+ http.Redirect(w, r, os.Getenv("ORIGIN")+"/login", 301)
}
type staticAssetPlugs struct {
@@ -21,6 +21,7 @@ type staticAssetPlugs struct {
}
type staticHtmlPlugs struct {
+ Origin string
CdnPrefix string
Footer template.HTML
}
@@ -56,9 +57,11 @@ func staticRouterInit(router *mux.Router) error {
gzip := (os.Getenv("GZIP_STATIC") == "true")
- asset[p] = []byte(prefix + string(contents))
+ subdir := pathStrip(os.Getenv("ORIGIN"))
+
+ asset[subdir+p] = []byte(prefix + string(contents))
if gzip {
- gzippedAsset[p], err = gzipStatic(asset[p])
+ gzippedAsset[subdir+p], err = gzipStatic(asset[subdir+p])
if err != nil {
logger.Errorf("error gzipping %s: %v", p, err)
return err
@@ -115,9 +118,15 @@ func staticRouterInit(router *mux.Router) error {
}
var buf bytes.Buffer
- t.Execute(&buf, &staticHtmlPlugs{CdnPrefix: os.Getenv("CDN_PREFIX"), Footer: template.HTML(string(footer))})
+ t.Execute(&buf, &staticHtmlPlugs{
+ Origin: os.Getenv("ORIGIN"),
+ CdnPrefix: os.Getenv("CDN_PREFIX"),
+ Footer: template.HTML(string(footer)),
+ })
- html[page] = buf.String()
+ subdir := pathStrip(os.Getenv("ORIGIN"))
+
+ html[subdir+page] = buf.String()
}
for _, page := range pages {
diff --git a/frontend/dashboard.html b/frontend/dashboard.html
index 7520304..2f6c2a6 100644
--- a/frontend/dashboard.html
+++ b/frontend/dashboard.html
@@ -12,9 +12,9 @@
diff --git a/frontend/footer.html b/frontend/footer.html
index d6b91bb..f0bd3ad 100644
--- a/frontend/footer.html
+++ b/frontend/footer.html
@@ -3,9 +3,9 @@
diff --git a/frontend/forgot.html b/frontend/forgot.html
index e910fd6..3a4186e 100644
--- a/frontend/forgot.html
+++ b/frontend/forgot.html
@@ -9,9 +9,9 @@
diff --git a/frontend/js/auth-common.js b/frontend/js/auth-common.js
index 94dcdd3..14317fa 100644
--- a/frontend/js/auth-common.js
+++ b/frontend/js/auth-common.js
@@ -5,7 +5,7 @@
// cookie is deleted.
global.loggedInRedirect = function() {
if (global.cookieGet("commentoOwnerToken") !== undefined)
- document.location = "/dashboard";
+ document.location = global.commentoOrigin + "/dashboard";
}
diff --git a/frontend/js/dashboard-danger.js b/frontend/js/dashboard-danger.js
index 0626984..fd6fca0 100644
--- a/frontend/js/dashboard-danger.js
+++ b/frontend/js/dashboard-danger.js
@@ -13,7 +13,7 @@
domainDelete(data.domains[data.cd].domain, function(success) {
if (success)
- document.location = '/dashboard';
+ document.location = global.commentoOrigin + '/dashboard';
});
}
diff --git a/frontend/js/login.js b/frontend/js/login.js
index ad9b86d..f43c07d 100644
--- a/frontend/js/login.js
+++ b/frontend/js/login.js
@@ -66,7 +66,7 @@
}
global.cookieSet("commentoOwnerToken", resp.ownerToken);
- document.location = "/dashboard";
+ document.location = global.commentoOrigin + "/dashboard";
});
};
diff --git a/frontend/js/logout.js b/frontend/js/logout.js
index c6195b9..e3e9182 100644
--- a/frontend/js/logout.js
+++ b/frontend/js/logout.js
@@ -2,7 +2,7 @@
global.logout = function() {
global.cookieSet("commentoOwnerToken", "");
- document.location = "/login";
+ document.location = global.commentoOrigin + "/login";
}
} (window, document));
diff --git a/frontend/js/reset.js b/frontend/js/reset.js
index 3b55bbb..a59676b 100644
--- a/frontend/js/reset.js
+++ b/frontend/js/reset.js
@@ -30,7 +30,7 @@
return
}
- document.location = "/login?changed=true";
+ document.location = global.commentoOrigin + "/login?changed=true";
});
}
diff --git a/frontend/js/self.js b/frontend/js/self.js
index 395aaf1..0e4c6c4 100644
--- a/frontend/js/self.js
+++ b/frontend/js/self.js
@@ -7,14 +7,14 @@
};
if (json.ownerToken === undefined) {
- document.location = "/login";
+ document.location = global.commentoOrigin + "/login";
return;
}
global.post(global.commentoOrigin + "/api/owner/self", json, function(resp) {
if (!resp.success || !resp.loggedIn) {
global.cookieDelete("commentoOwnerToken");
- document.location = "/login";
+ document.location = global.commentoOrigin + "/login";
return;
}
diff --git a/frontend/js/signup.js b/frontend/js/signup.js
index e248139..bbc1819 100644
--- a/frontend/js/signup.js
+++ b/frontend/js/signup.js
@@ -34,9 +34,9 @@
}
if (resp.confirmEmail)
- document.location = "/confirm-email";
+ document.location = global.commentoOrigin + "/confirm-email";
else
- document.location = "/login?signedUp=true";
+ document.location = global.commentoOrigin + "/login?signedUp=true";
});
};
diff --git a/frontend/login.html b/frontend/login.html
index b19e76e..0382c3c 100644
--- a/frontend/login.html
+++ b/frontend/login.html
@@ -9,9 +9,9 @@