Skip to content

Commit

Permalink
fix: domain and routing
Browse files Browse the repository at this point in the history
  • Loading branch information
axyut committed Dec 17, 2024
1 parent 5760fee commit 2a063fa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ admin.get("/", (c) => {

const home = new Hono<AppBindings>();
home.get("/", (c) => {
const domain = c.env.API_DOMAIN;
const session = getCookie(c, "session");
let loggedIn = false;
if (session) {
Expand All @@ -35,7 +36,7 @@ home.get("/", (c) => {
<html lang="en">
${Header()}
<body>
${Content(loggedIn)}
${Content(loggedIn, domain)}
</body>
</html>
`);
Expand All @@ -54,7 +55,7 @@ const Header = () => html`
</head>
`;

const Content = (loggedIn: boolean) => html`
const Content = (loggedIn: boolean, domain: string) => html`
<div>
<h1>Welcome to BOSC API</h1>
<p>
Expand All @@ -64,13 +65,13 @@ const Content = (loggedIn: boolean) => html`
<a href="/api">API</a>
<h1>Login as a Club Executive</h1>
${loggedIn ? LogoutContent() : LoginContent()}
${loggedIn ? LogoutContent() : LoginContent(domain)}
</div>
`;

const LoginContent = () => html`
const LoginContent = (domain: string) => html`
<div id="login">
<a href="http://localhost:8787/auth/google?redirect=http://localhost:8787">
<a href="${domain}/auth/google?redirect=${domain}">
<img
src="/google_signin_light.png"
alt="Sign in with Google"
Expand Down

0 comments on commit 2a063fa

Please sign in to comment.