Skip to content

Commit c63a3b1

Browse files
committed
auth callback page powered by hono ssr
1 parent 0226c2d commit c63a3b1

File tree

6 files changed

+310
-140
lines changed

6 files changed

+310
-140
lines changed

apps/api/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"@hono/zod-validator": "^0.7.3",
1313
"@supabase/supabase-js": "^2.58.0",
1414
"@t3-oss/env-core": "^0.13.8",
15+
"@tailwindcss/vite": "^4.1.14",
1516
"hono": "^4.9.10",
17+
"tailwindcss": "^4.1.14",
1618
"zod": "^4.1.12"
1719
},
1820
"devDependencies": {

apps/api/src/index.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,51 @@ import { z } from "zod";
55

66
import { getEnv } from "./env";
77
import { supabaseMiddleware } from "./middleware/supabase";
8+
import { renderer } from "./renderer";
89
import type { Env } from "./types";
910

1011
const app = new Hono<Env>();
1112
app.use("/v1", supabaseMiddleware());
1213

1314
app.get("/health", (c) => c.text("OK"));
14-
app.get("/", (c) => {
15-
const allParams = c.req.query();
15+
app.get("/", renderer, (c) => {
16+
const params = c.req.query();
17+
const code = params.code;
18+
const deeplink = "hypr://auth/callback?" + new URLSearchParams(params).toString();
1619

1720
return c.render(
18-
<pre>{JSON.stringify(allParams, null, 2)}</pre>,
21+
<div class="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4">
22+
<div class="bg-white rounded-2xl shadow-xl p-8 max-w-md w-full text-center">
23+
<div class="space-y-4">
24+
<p class="font-mono text-lg bg-gray-100 p-2 rounded">Code: {code}</p>
25+
<button
26+
id="open"
27+
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors"
28+
>
29+
Open App
30+
</button>
31+
</div>
32+
33+
<script
34+
dangerouslySetInnerHTML={{
35+
__html: `
36+
function trigger() {
37+
const params = new URLSearchParams(window.location.search);
38+
const deeplink = 'hypr://auth/callback?' + new URLSearchParams(params).toString();
39+
window.open(deeplink);
40+
}
41+
42+
window.addEventListener('load', () => {
43+
trigger();
44+
});
45+
document.getElementById('open').addEventListener('click', () => {
46+
trigger();
47+
});
48+
`,
49+
}}
50+
/>
51+
</div>
52+
</div>,
1953
);
2054
});
2155

apps/api/src/style.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
h1 {
2-
font-family: Arial, Helvetica, sans-serif;
3-
}
1+
@import "tailwindcss";

apps/api/vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { cloudflare } from "@cloudflare/vite-plugin";
2+
import tailwindcss from "@tailwindcss/vite";
23
import { defineConfig } from "vite";
34
import ssrPlugin from "vite-ssr-components/plugin";
45

56
export default defineConfig({
6-
plugins: [cloudflare(), ssrPlugin()],
7+
plugins: [tailwindcss(), cloudflare(), ssrPlugin()],
78
});

apps/desktop2/src/routes/app/auth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function Component() {
6060
provider: Provider;
6161
}) => {
6262
if (auth?.supabase) {
63-
const redirectUrl = "hypr://auth/callback";
63+
const redirectUrl = "https://api.hyprnote.com/auth/callback";
6464
const { data, error } = await auth.supabase.auth.signInWithOAuth({
6565
provider,
6666
options: {

0 commit comments

Comments
 (0)