File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ export async function POST(request: Request) {
8787 return forbidden ( ) ;
8888 }
8989
90- const sessionId = uuid ( websiteId , hostname , ip , userAgent ) ;
90+ const sessionId = uuid ( websiteId , ip , userAgent ) ;
9191
9292 // Find session
9393 if ( ! clickhouse . enabled && ! cache ?. sessionId ) {
Original file line number Diff line number Diff line change @@ -86,13 +86,13 @@ function decodeHeader(s: string | undefined | null): string | undefined | null {
8686 return Buffer . from ( s , 'latin1' ) . toString ( 'utf-8' ) ;
8787}
8888
89- export async function getLocation ( ip : string = '' , headers : Headers ) {
89+ export async function getLocation ( ip : string = '' , headers : Headers , hasPayloadIP : boolean ) {
9090 // Ignore local ips
9191 if ( await isLocalhost ( ip ) ) {
9292 return ;
9393 }
9494
95- if ( ! process . env . SKIP_LOCATION_HEADERS ) {
95+ if ( ! hasPayloadIP && ! process . env . SKIP_LOCATION_HEADERS ) {
9696 // Cloudflare headers
9797 if ( headers . get ( 'cf-ipcountry' ) ) {
9898 const country = decodeHeader ( headers . get ( 'cf-ipcountry' ) ) ;
@@ -147,7 +147,7 @@ export async function getLocation(ip: string = '', headers: Headers) {
147147export async function getClientInfo ( request : Request , payload : Record < string , any > ) {
148148 const userAgent = payload ?. userAgent || request . headers . get ( 'user-agent' ) ;
149149 const ip = payload ?. ip || getIpAddress ( request . headers ) ;
150- const location = await getLocation ( ip , request . headers ) ;
150+ const location = await getLocation ( ip , request . headers , ! ! payload ?. ip ) ;
151151 const country = payload ?. userAgent || location ?. country ;
152152 const subdivision1 = location ?. subdivision1 ;
153153 const subdivision2 = location ?. subdivision2 ;
You can’t perform that action at this time.
0 commit comments