@cocalc/hub
Version:
CoCalc: Backend webserver component
32 lines (31 loc) • 1.36 kB
JavaScript
;
/* Save other paths in # part of URL then redirect to the single page app.
That this happened is assumed, e.g., in packages/static/src/init-app-base-path.ts
This redirect is *undone* in @cocalc/frontend/client/handle-hash-url.ts
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const base_path_1 = __importDefault(require("@cocalc/backend/base-path"));
const logger_1 = require("@cocalc/hub/logger");
// All top level page "entry points" in the webapp must be listed here.
// Should be consistent with what is handled in @cocalc/frontend/history.ts
// and @cocalc/frontend/app/actions.ts
const ROUTES = ["admin", "projects", "settings", "notifications"];
function init(router) {
const winston = (0, logger_1.getLogger)("app-redirect");
const v = [];
for (const path of ROUTES) {
v.push(`/${path}*`);
}
router.get(v, (req, res) => {
winston.debug(req.url);
const url = new URL("http://host");
url.searchParams.set("target", req.url);
res.redirect((0, path_1.join)(base_path_1.default, "static/app.html") + url.search);
});
}
exports.default = init;
//# sourceMappingURL=app-redirect.js.map