Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
rebuild vercel request geo header
Marc Seitz99751d1878cd
diff --git a/lib/types.ts b/lib/types.tsindex b13f97b9..ef17d927 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -30,3 +30,11 @@ export interface LinkWithViews extends Link {export interface LinkWithDocument extends Link {document: Document;}++export interface Geo {+ city?: string | undefined;+ country?: string | undefined;+ region?: string | undefined;+ latitude?: string | undefined;+ longitude?: string | undefined;+}\ No newline at end of filediff --git a/lib/utils/geo.ts b/lib/utils/geo.tsnew file mode 100644index 00000000..dd98f470--- /dev/null+++ b/lib/utils/geo.ts@@ -0,0 +1,32 @@+import { Geo } from "../types";++export function getGeoData(headers: {+ [key: string]: string | string[] | undefined;+}): Geo {+ return {+ city: Array.isArray(headers["x-vercel-ip-city"])+ ? headers["x-vercel-ip-city"][0]+ : headers["x-vercel-ip-city"],+ region: Array.isArray(headers["x-vercel-ip-region"])+ ? headers["x-vercel-ip-region"][0]+ : headers["x-vercel-ip-region"],+ country: Array.isArray(headers["x-vercel-ip-country"])+ ? headers["x-vercel-ip-country"][0]+ : headers["x-vercel-ip-country"],+ latitude: Array.isArray(headers["x-vercel-ip-latitude"])+ ? headers["x-vercel-ip-latitude"][0]+ : headers["x-vercel-ip-latitude"],+ longitude: Array.isArray(headers["x-vercel-ip-longitude"])+ ? headers["x-vercel-ip-longitude"][0]+ : headers["x-vercel-ip-longitude"],+ };+}+++export const LOCALHOST_GEO_DATA = {+ city: "Munich",+ region: "BY",+ country: "DE",+ latitude: "48.137154",+ longitude: "11.576124",+};