File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11import { cors } from "@elysiajs/cors" ;
22import { Elysia } from "elysia" ;
3+ import { auth } from "./api/auth/index" ;
34import { authRoutes } from "./api/auth/routes" ;
45import {
56 formFieldRoutes ,
@@ -57,7 +58,16 @@ const app = new Elysia()
5758 message : "Internal server error" ,
5859 } ;
5960 } )
60- . get ( "/" , ( ) => "🦊 Elysia server started" )
61+ . get ( "/" , async ( { request, set } ) => {
62+ // Check if user has active session and redirect to frontend
63+ const session = await auth . api . getSession ( { headers : request . headers } ) ;
64+ if ( session ) {
65+ const frontendUrl = process . env . FRONTEND_URL || "http://localhost:5173" ;
66+ set . redirect = `${ frontendUrl } /dashboard` ;
67+ return ;
68+ }
69+ return "🦊 Elysia server started" ;
70+ } )
6171 . use ( authRoutes )
6272 . use ( publicFormRoutes ) // Public routes first (no auth)
6373 . use ( publicFormFieldRoutes ) // Public form fields (no auth)
You can’t perform that action at this time.
0 commit comments