summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-22 12:13:13 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-22 12:13:13 +1100
commitb47b6de10252946f3079b4aae5fba013cb6f27bf (patch)
tree6edaedabd62cabb1a2711e2b8a64b8a6e623126e
parentDisable test client by default (diff)
downloadserver-b47b6de10252946f3079b4aae5fba013cb6f27bf.tar.xz
Fix redirect when test client disabled
-rw-r--r--src/api/middlewares/TestClient.ts18
-rw-r--r--src/util/config/types/subconfigurations/defaults/GuildDefaults.ts1
2 files changed, 9 insertions, 10 deletions
diff --git a/src/api/middlewares/TestClient.ts b/src/api/middlewares/TestClient.ts

index a932caf6..e55a7c7b 100644 --- a/src/api/middlewares/TestClient.ts +++ b/src/api/middlewares/TestClient.ts
@@ -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); diff --git a/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts b/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts
index d6ff7697..27e8eae7 100644 --- a/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts +++ b/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts
@@ -4,5 +4,4 @@ export class GuildDefaults { afkTimeout: number = 300; defaultMessageNotifications: number = 1; explicitContentFilter: number = 0; - test: number = 123; } \ No newline at end of file