From edeb6c6965cc685b2dab1347af3920078ca01738 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 9 Jun 2022 13:59:09 +0200 Subject: [PATCH 1/3] fix: Plausible script and middlewares --- src/routes/webhooks/traefik/main.json.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/routes/webhooks/traefik/main.json.ts b/src/routes/webhooks/traefik/main.json.ts index 1bd277974..02270d73e 100644 --- a/src/routes/webhooks/traefik/main.json.ts +++ b/src/routes/webhooks/traefik/main.json.ts @@ -7,7 +7,7 @@ import { checkContainer } from '$lib/haproxy'; import type { RequestHandler } from '@sveltejs/kit'; function configureMiddleware( - { id, container, port, domain, nakedDomain, isHttps, isWWW, isDualCerts, scriptName }, + { id, container, port, domain, nakedDomain, isHttps, isWWW, isDualCerts, scriptName, type }, traefik ) { if (isHttps) { @@ -125,8 +125,10 @@ function configureMiddleware( } } } - if (scriptName !== 'plausible.js') { + + if (type === 'plausibleanalytics' && scriptName !== 'plausible.js') { if (!traefik.http.routers[`${id}`].middlewares.includes(`${id}-redir`)) { + console.log(traefik.http.routers[`${id}`].middlewares); traefik.http.routers[`${id}`].middlewares.push(`${id}-redir`); } if (!traefik.http.routers[`${id}-secure`].middlewares.includes(`${id}-redir`)) { @@ -343,11 +345,11 @@ export const get: RequestHandler = async (event) => { replacement: '/js/plausible.js' } }; - if (traefik.http.routers[id].middlewares.length > 0) { - traefik.http.routers[id].middlewares.push(`${id}-redir`); - } else { - traefik.http.routers[id].middlewares = [`${id}-redir`]; - } + // if (traefik.http.routers[id].middlewares.length > 0) { + // traefik.http.routers[id].middlewares.push(`${id}-redir`); + // } else { + // traefik.http.routers[id].middlewares = [`${id}-redir`]; + // } } } for (const coolify of data.coolify) { From 0e3bd8584785c39ffcfbc4539620342d91d01e41 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 9 Jun 2022 14:00:08 +0200 Subject: [PATCH 2/3] fix: remove console log --- src/routes/webhooks/traefik/main.json.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/webhooks/traefik/main.json.ts b/src/routes/webhooks/traefik/main.json.ts index 02270d73e..100f1bbf5 100644 --- a/src/routes/webhooks/traefik/main.json.ts +++ b/src/routes/webhooks/traefik/main.json.ts @@ -128,7 +128,6 @@ function configureMiddleware( if (type === 'plausibleanalytics' && scriptName !== 'plausible.js') { if (!traefik.http.routers[`${id}`].middlewares.includes(`${id}-redir`)) { - console.log(traefik.http.routers[`${id}`].middlewares); traefik.http.routers[`${id}`].middlewares.push(`${id}-redir`); } if (!traefik.http.routers[`${id}-secure`].middlewares.includes(`${id}-redir`)) { From 1192346ce3aa4e98c862fdff06eef9cedccc5762 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 9 Jun 2022 14:00:41 +0200 Subject: [PATCH 3/3] fix: remove comments --- src/routes/webhooks/traefik/main.json.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/routes/webhooks/traefik/main.json.ts b/src/routes/webhooks/traefik/main.json.ts index 100f1bbf5..83b6badeb 100644 --- a/src/routes/webhooks/traefik/main.json.ts +++ b/src/routes/webhooks/traefik/main.json.ts @@ -344,11 +344,6 @@ export const get: RequestHandler = async (event) => { replacement: '/js/plausible.js' } }; - // if (traefik.http.routers[id].middlewares.length > 0) { - // traefik.http.routers[id].middlewares.push(`${id}-redir`); - // } else { - // traefik.http.routers[id].middlewares = [`${id}-redir`]; - // } } } for (const coolify of data.coolify) {