Compare commits

..

No commits in common. "79e324aace4e2a61f81670e2bc2c7424a3311a40" and "c9f522b24d7ebfef59ccbe4b3976f1b40f9f6707" have entirely different histories.

3 changed files with 15 additions and 20 deletions

View file

@ -42,7 +42,7 @@ RUN set -x \
&& apk add --no-cache curl
# Script dependencies
RUN pnpm add npm-run-all dotenv chalk semver prisma@6.18.0 @prisma/adapter-pg@6.18.0
RUN pnpm add npm-run-all dotenv chalk semver prisma@6.16.3 @prisma/adapter-pg@6.16.3
# Permissions for prisma
RUN chown -R nextjs:nodejs node_modules/.pnpm/

View file

@ -30,18 +30,10 @@ const PROVIDER_HEADERS = [
},
];
export function getDevice(userAgent: string, screen: string = '') {
export function getDevice(userAgent: string) {
const { device } = UAParser(userAgent);
const [width] = screen.split('x');
const type = device?.type || 'desktop';
if (type === 'desktop' && screen && +width <= 1920) {
return 'laptop';
}
return type;
return device?.type || 'desktop';
}
function getRegionCode(country: string, region: string) {
@ -116,7 +108,7 @@ export async function getClientInfo(request: Request, payload: Record<string, an
const city = safeDecodeURIComponent(location?.city);
const browser = browserName(userAgent);
const os = detectOS(userAgent) as string;
const device = getDevice(userAgent, payload?.screen);
const device = getDevice(userAgent);
return { userAgent, browser, os, ip, country, region, city, device };
}

View file

@ -1,16 +1,19 @@
// The order here is important and influences how IPs are detected by lib/detect.ts
// Please do not change the order unless you know exactly what you're doing - read https://developers.cloudflare.com/fundamentals/reference/http-headers/
export const IP_ADDRESS_HEADERS = [
'x-real-ip',
'x-forwarded-for',
'cf-connecting-ip', // Cloudflare
'fastly-client-ip', // Fastly
'true-client-ip', // Akamai
'x-nf-client-connection-ip', // Netlify
'do-connecting-ip', // Digital Ocean
'x-appengine-user-ip', // Google App Ending
'x-client-ip',
'x-forwarded-for',
'cf-connecting-ip', // This should be *after* x-forwarded-for, so that x-forwarded-for is respected if present
'do-connecting-ip',
'fastly-client-ip',
'true-client-ip',
'x-real-ip',
'x-cluster-client-ip',
'x-forwarded',
'forwarded',
'x-appengine-user-ip',
'x-nf-client-connection-ip',
'x-real-ip',
];
export function getIpAddress(headers: Headers) {