fix: Plausible script and middlewares

This commit is contained in:
Andras Bacsai 2022-06-09 13:59:09 +02:00
parent 155410bd44
commit edeb6c6965

View File

@ -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) {