Skip to content

Commit 7abf1d4

Browse files
Merge pull request #41 from Nandgopal-R/feat/deployment
Add automatic redirect after Google OAuth
2 parents f5647a7 + 14c1206 commit 7abf1d4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cors } from "@elysiajs/cors";
22
import { Elysia } from "elysia";
3+
import { auth } from "./api/auth/index";
34
import { authRoutes } from "./api/auth/routes";
45
import {
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)

0 commit comments

Comments
 (0)