File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed
Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,12 @@ app.use(cors({
1818
1919app . all ( "/api/auth/*" , toNodeHandler ( auth ) ) ;
2020
21- /*
2221app . get ( "/api/session" , async ( req , res ) => {
2322 const session = await auth . api . getSession ( {
2423 headers : fromNodeHeaders ( req . headers ) ,
2524 } ) ;
2625 return res . json ( session ) ;
2726} ) ;
28- */
2927
3028app . use ( express . json ( ) ) // use this after better auth
3129
Original file line number Diff line number Diff line change @@ -6,24 +6,34 @@ import CalcLogo from "../components/CalcLogo"
66
77import { authClient } from "../lib/auth-client" ;
88import { Avatar , AvatarFallback , AvatarImage } from "../components/ui/avatar"
9- import { useState } from "react" ;
9+ import { useEffect } from "react" ;
10+ import axios from "axios" ;
1011
1112function RootLayout ( ) {
1213
13- const oldSession = authClient . useSession ( ) ;
14+ const serverUrl = import . meta . env . VITE_SERVER_URL || 'http://localhost:3000'
1415
15- const [ session , setSession ] = useState ( oldSession )
16+ const session = authClient . useSession ( ) ;
1617
17- // function to get the session
18- const initializeSession = async ( ) => {
19- await authClient . getSession ( ) ; // getting session value
2018
21- const newSession = authClient . useSession ( )
22-
23- setSession ( newSession ) ;
19+ const requestSession = async ( ) => {
20+
21+ try {
22+ const response = await axios . get ( serverUrl + '/api/session' )
23+
24+ console . log ( response )
25+ }
26+ catch ( e ) {
27+ console . error ( "session error: " , e )
28+ }
2429 }
2530
26- initializeSession ( )
31+ useEffect ( ( ) => {
32+
33+ requestSession ( )
34+
35+ } , [ ] )
36+
2737
2838 return (
2939 < >
You can’t perform that action at this time.
0 commit comments