Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
ae5dad8e
Commit
ae5dad8e
authored
Nov 17, 2025
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the new way to updated device id in header
parent
e75ab156
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
page.tsx
src/app/(auth)/login/page.tsx
+2
-2
SeonProvider.tsx
src/app/SeonProvider.tsx
+7
-0
layout.tsx
src/app/layout.tsx
+2
-2
baseQuery.ts
src/services/baseQuery.ts
+10
-2
No files found.
src/app/(auth)/login/page.tsx
View file @
ae5dad8e
...
@@ -4,8 +4,8 @@ import React from 'react'
...
@@ -4,8 +4,8 @@ import React from 'react'
export
default
function
Login
()
{
export
default
function
Login
()
{
return
(
return
(
<
SeonProvider
>
//
<SeonProvider>
<
LoginPage
/>
<
LoginPage
/>
</
SeonProvider
>
//
</SeonProvider>
)
)
}
}
src/app/SeonProvider.tsx
View file @
ae5dad8e
"use client"
;
"use client"
;
import
{
setGlobalDeviceId
}
from
"@/services/baseQuery"
;
import
React
,
{
createContext
,
useContext
,
useEffect
,
useState
}
from
"react"
;
import
React
,
{
createContext
,
useContext
,
useEffect
,
useState
}
from
"react"
;
type
SeonContextType
=
{
type
SeonContextType
=
{
...
@@ -40,6 +41,7 @@ export const SeonProvider: React.FC<{ children: React.ReactNode }> = ({ children
...
@@ -40,6 +41,7 @@ export const SeonProvider: React.FC<{ children: React.ReactNode }> = ({ children
const
session
=
await
seon
.
getSession
();
const
session
=
await
seon
.
getSession
();
// console.log("Device fingerprint session:", session);
// console.log("Device fingerprint session:", session);
setDeviceId
(
session
);
setDeviceId
(
session
);
setGlobalDeviceId
(
session
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"SEON init error:"
,
err
);
console
.
error
(
"SEON init error:"
,
err
);
}
finally
{
}
finally
{
...
@@ -58,6 +60,11 @@ export const SeonProvider: React.FC<{ children: React.ReactNode }> = ({ children
...
@@ -58,6 +60,11 @@ export const SeonProvider: React.FC<{ children: React.ReactNode }> = ({ children
};
};
},
[]);
},
[]);
useEffect
(()
=>
{
if
(
deviceId
)
{
setGlobalDeviceId
(
deviceId
);
}
},
[
deviceId
]);
return
(
return
(
<
SeonContext
.
Provider
value=
{
{
deviceId
,
loading
}
}
>
<
SeonContext
.
Provider
value=
{
{
deviceId
,
loading
}
}
>
{
children
}
{
children
}
...
...
src/app/layout.tsx
View file @
ae5dad8e
...
@@ -51,14 +51,14 @@ export default function RootLayout({
...
@@ -51,14 +51,14 @@ export default function RootLayout({
<
html
lang=
"en"
>
<
html
lang=
"en"
>
{
/* className="dark" */
}
{
/* className="dark" */
}
<
body
className=
{
`${inter.className} scroll-smooth`
}
cz
-
shortcut
-
listen=
"true"
>
<
body
className=
{
`${inter.className} scroll-smooth`
}
cz
-
shortcut
-
listen=
"true"
>
{
/* <SeonProvider> */
}
<
SeonProvider
>
<
ProviderWrapper
>
<
ProviderWrapper
>
<
React
.
Suspense
fallback=
{
<
div
/>
}
>
<
React
.
Suspense
fallback=
{
<
div
/>
}
>
<
TopLoader
/>
<
TopLoader
/>
</
React
.
Suspense
>
</
React
.
Suspense
>
{
children
}
{
children
}
</
ProviderWrapper
>
</
ProviderWrapper
>
{
/* </SeonProvider> */
}
</
SeonProvider
>
</
body
>
</
body
>
</
html
>
</
html
>
);
);
...
...
src/services/baseQuery.ts
View file @
ae5dad8e
...
@@ -2,12 +2,16 @@
...
@@ -2,12 +2,16 @@
import
{
RootState
}
from
"@/hooks/store"
;
import
{
RootState
}
from
"@/hooks/store"
;
import
{
fetchBaseQuery
}
from
"@reduxjs/toolkit/query/react"
;
import
{
fetchBaseQuery
}
from
"@reduxjs/toolkit/query/react"
;
let
globalDeviceId
:
string
|
undefined
=
undefined
;
export
const
setGlobalDeviceId
=
(
id
?:
string
)
=>
{
globalDeviceId
=
id
;
};
export
const
baseQuery
=
fetchBaseQuery
({
export
const
baseQuery
=
fetchBaseQuery
({
// Use your Next.js frontend URL + proxy path
// Example: https://sweepstake.webjuwa.com/api/backend OR localhost:3000/api/backend
baseUrl
:
baseUrl
:
(
process
.
env
.
NEXT_PUBLIC_FRONTEND_URL
||
""
)
+
"/api/backend"
,
(
process
.
env
.
NEXT_PUBLIC_FRONTEND_URL
||
""
)
+
"/api/backend"
,
credentials
:
"include"
,
credentials
:
"include"
,
prepareHeaders
:
(
headers
,
{
getState
})
=>
{
prepareHeaders
:
(
headers
,
{
getState
})
=>
{
const
token
=
(
getState
()
as
RootState
).
auth
.
access_token
;
const
token
=
(
getState
()
as
RootState
).
auth
.
access_token
;
...
@@ -15,6 +19,10 @@ export const baseQuery = fetchBaseQuery({
...
@@ -15,6 +19,10 @@ export const baseQuery = fetchBaseQuery({
headers
.
set
(
"Accept"
,
"application/json"
);
headers
.
set
(
"Accept"
,
"application/json"
);
// headers.set("Content-Type", "application/json");
// headers.set("Content-Type", "application/json");
console
.
log
(
"deviceId"
,
globalDeviceId
)
if
(
globalDeviceId
)
{
headers
.
set
(
"device_id"
,
globalDeviceId
);
}
if
(
token
)
{
if
(
token
)
{
headers
.
set
(
"Authorization"
,
`Bearer
${
token
}
`
);
headers
.
set
(
"Authorization"
,
`Bearer
${
token
}
`
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment