diff --git a/next.config.js b/next.config.js index b7d7331d..33a43ee7 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,8 @@ require('dotenv').config(); const path = require('path'); const pkg = require('./package.json'); +const TRACKER_SCRIPT = '/script.js'; + const basePath = process.env.BASE_PATH; const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT; const cloudMode = process.env.CLOUD_MODE; @@ -14,6 +16,7 @@ const forceSSL = process.env.FORCE_SSL; const frameAncestors = process.env.ALLOWED_FRAME_URLS; const privateMode = process.env.PRIVATE_MODE; const trackerScriptName = process.env.TRACKER_SCRIPT_NAME; +const trackerScriptURL = process.env.TRACKER_SCRIPT_URL; const contentSecurityPolicy = [ `default-src 'self'`, @@ -58,13 +61,20 @@ const headers = [ headers: defaultHeaders, }, { - source: '/script.js', + source: TRACKER_SCRIPT, headers: trackerHeaders, }, ]; const rewrites = []; +if (trackerScriptURL) { + rewrites.push({ + source: TRACKER_SCRIPT, + destination: trackerScriptURL, + }); +} + if (collectApiEndpoint) { rewrites.push({ source: collectApiEndpoint, @@ -100,7 +110,7 @@ if (trackerScriptName) { rewrites.push({ source: normalizedSource, - destination: '/script.js', + destination: TRACKER_SCRIPT, }); headers.push({ @@ -184,10 +194,6 @@ const config = { async rewrites() { return [ ...rewrites, - { - source: '/script.js', - destination: 'https://tracker-script.umami.dev/', - }, { source: '/telemetry.js', destination: '/api/scripts/telemetry', diff --git a/package.json b/package.json index c78a1137..77c40cae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "umami", - "version": "2.13.2", + "version": "2.14.0", "description": "A simple, fast, privacy-focused alternative to Google Analytics.", "author": "Umami Software, Inc. ", "license": "MIT", diff --git a/rollup.tracker.config.mjs b/rollup.tracker.config.mjs index 4b1f0e0e..05df2879 100644 --- a/rollup.tracker.config.mjs +++ b/rollup.tracker.config.mjs @@ -5,7 +5,7 @@ import { terser } from 'rollup-plugin-terser'; export default { input: 'src/tracker/index.js', output: { - file: 'public/tracker.js', + file: 'public/script.js', format: 'iife', }, plugins: [