Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fixed auth check.

Mike Caoaaf8b1935f71
diff --git a/next-env.d.ts b/next-env.d.ts
index 725dd6f24..40c3d6809 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
-/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
diff --git a/src/lib/detect.ts b/src/lib/detect.ts
index fe1c21248..835040958 100644
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@ -86,7 +86,7 @@ function decodeHeader(s: string | undefined | null): string | undefined | null {
return Buffer.from(s, 'latin1').toString('utf-8');
}
-export async function getLocation(ip: string, headers: Headers) {
+export async function getLocation(ip: string = '', headers: Headers) {
// Ignore local ips
if (await isLocalhost(ip)) {
return;
diff --git a/src/lib/request.ts b/src/lib/request.ts
index dc7212253..c71684b94 100644
--- a/src/lib/request.ts
+++ b/src/lib/request.ts
@@ -22,6 +22,7 @@ export async function parseRequest(
let query = Object.fromEntries(url.searchParams);
let body = await getJsonBody(request);
let error: () => void | undefined;
+ let auth = null;
if (schema) {
const isGet = request.method === 'GET';
@@ -36,10 +37,12 @@ export async function parseRequest(
}
}
- const auth = !error && !options?.skipAuth ? await checkAuth(request) : null;
+ if (!options?.skipAuth && !error) {
+ auth = await checkAuth(request);
- if (!error && !auth) {
- error = () => unauthorized();
+ if (!auth) {
+ error = () => unauthorized();
+ }
}
return { url, query, body, auth, error };