diff --git a/api/main.ts b/api/main.ts index 5b4c400..a037abe 100644 --- a/api/main.ts +++ b/api/main.ts @@ -15,8 +15,7 @@ type AppState = { const router = new Router(); -const hostname = "localhost"; -const deployHostname = "forums.warabi.co" +const hostname = "forums.warabi.co"; const authPath = "/auth"; const port = 8000; @@ -42,8 +41,8 @@ export interface SteamUser { } export const Steam = new SteamAuth({ - realm: `http://${hostname}:${port}`, - returnUrl: `https://${hostname}:${port}${authPath}/return`, + realm: `https://${hostname}`, + returnUrl: `https://${hostname}${authPath}/return`, apiKey: Deno.env.get("STEAM_API_KEY"), }); @@ -51,6 +50,7 @@ router.get(`${authPath}/login`, async (ctx) => { try { const redirectUrl = await Steam.getRedirectUrl() as string; ctx.response.body = { url: redirectUrl }; + console.log("Redirecting to:", redirectUrl); } catch (e) { ctx.response.body = `Error: ${e}`; } @@ -58,10 +58,13 @@ router.get(`${authPath}/login`, async (ctx) => { router.get(`${authPath}/return`, async (ctx) => { try { + console.log("Authenticating user..."); const user = await Steam.authenticate(ctx) as SteamUser; + console.log(user); ctx.state.session.set("steamid", user.steamid); ctx.state.session.set("user", user); - ctx.response.redirect(`https://${deployHostname}/signedIn`); + console.log("Authenticated user:", user); + ctx.response.redirect("/"); } catch (e) { ctx.response.body = `Error: ${e}`; } @@ -94,7 +97,7 @@ router.get("/api/dinosaurs/:dinosaur", (context) => { }); const store = new CookieStore(Deno.env.get("SESSION_COOKIE_KEY") as string, { - sessionDataCookieName: "warbforums_sessionData", + sessionDataCookieName: "warbforums_sessionData" }); const app = new Application();