From edeb6c6965cc685b2dab1347af3920078ca01738 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 9 Jun 2022 13:59:09 +0200 Subject: [PATCH] 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) {