mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Adds support for customCollectEndpoint
This commit is contained in:
parent
43f89a1cdc
commit
ae48ff0e68
@ -1,5 +1,19 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
function customCollectEndpoint(req) {
|
||||
const collectEndpoint = process.env.API_COLLECT_ENDPOINT;
|
||||
|
||||
if (collectEndpoint) {
|
||||
const url = req.nextUrl.clone();
|
||||
const { pathname } = url;
|
||||
|
||||
if (pathname.endsWith(collectEndpoint)) {
|
||||
url.pathname = '/api/collect';
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function customScriptName(req) {
|
||||
const scriptName = process.env.TRACKER_SCRIPT_NAME;
|
||||
|
||||
@ -24,7 +38,7 @@ function forceSSL(req, res) {
|
||||
}
|
||||
|
||||
export function middleware(req) {
|
||||
const fns = [customScriptName];
|
||||
const fns = [customCollectEndpoint, customScriptName];
|
||||
|
||||
for (const fn of fns) {
|
||||
const res = fn(req);
|
||||
|
Loading…
Reference in New Issue
Block a user