1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 04:32:35 +01:00

Fix redirect when test client disabled

This commit is contained in:
Madeline 2022-12-22 12:13:13 +11:00
parent 22fb62673a
commit b47b6de102
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 9 additions and 10 deletions

View File

@ -11,21 +11,21 @@ export default function TestClient(app: Application) {
app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "public")));
app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "cache")));
app.get("*", (req, res, next) => {
if (Config.get().client.useTestClient) return next();
return res.redirect("/api/ping")
})
// Test client is disabled, so don't need to run any more. Above should probably be moved somewhere?
if (!Config.get().client.useTestClient) return;
if (!Config.get().client.useTestClient) {
app.get("*", (req, res) => {
return res.redirect("/api/ping");
});
return;
}
const agent = new ProxyAgent();
let html = fs.readFileSync(path.join(ASSET_FOLDER_PATH, "client_test", "index.html"), { encoding: "utf-8" });
html = applyEnv(html); // update window.GLOBAL_ENV according to config
html = applyPlugins(html); // inject our plugins
app.use("/assets/plugins", express.static(path.join(ASSET_FOLDER_PATH, "plugins")));
app.use("/assets/inline-plugins", express.static(path.join(ASSET_FOLDER_PATH, "inline-plugins")));
@ -38,7 +38,7 @@ export default function TestClient(app: Application) {
delete req.headers.host;
if (req.params.file.endsWith(".map")) return res.status(404);
let response: FetchResponse;
let buffer: Buffer;
const cache = assetCache.get(req.params.file);

View File

@ -4,5 +4,4 @@ export class GuildDefaults {
afkTimeout: number = 300;
defaultMessageNotifications: number = 1;
explicitContentFilter: number = 0;
test: number = 123;
}