diff --git a/apps/api/src/routes/auth.ts b/apps/api/src/routes/auth.ts index bbc09b4..b105507 100644 --- a/apps/api/src/routes/auth.ts +++ b/apps/api/src/routes/auth.ts @@ -314,12 +314,18 @@ export const authRoutes = new Elysia({ prefix: '/api/v1/auth' }) } const token = await createSession(user.id); - set.headers['Set-Cookie'] = createSessionCookie(token, request.headers); + const sessionCookie = createSessionCookie(token, request.headers); authCounter.labels('login', 'true').inc(); const successUrl = `${env.webAppUrl}/login?token=${encodeURIComponent(token)}`; - if (platform === 'tauri') return renderTauriDeepLinkPage(successUrl); + if (platform === 'tauri') { + // Inject Set-Cookie into the response so the browser gets it on redirect + const resp = renderTauriDeepLinkPage(successUrl); + resp.headers.set('Set-Cookie', sessionCookie); + return resp; + } + set.headers['Set-Cookie'] = sessionCookie; set.status = 302; set.headers['Location'] = successUrl; } catch (err) { diff --git a/apps/tauri/tauri.conf.json b/apps/tauri/tauri.conf.json index cc0c025..d12675c 100644 --- a/apps/tauri/tauri.conf.json +++ b/apps/tauri/tauri.conf.json @@ -4,10 +4,10 @@ "version": "0.1.0", "identifier": "com.zeavis.edu", "build": { - "frontendDist": "../web/dist", + "frontendDist": "../web/dist-tauri", "devUrl": "http://localhost:5173", - "beforeBuildCommand": "cd ../web && bun run build", - "beforeDevCommand": "cd ../web && bun run dev" + "beforeBuildCommand": "echo 'Nothing to build (APK loads live web content)'", + "beforeDevCommand": "echo 'Dev mode - connect to localhost:5173'" }, "app": { "withGlobalTauri": false, diff --git a/apps/web/dist-tauri/index.html b/apps/web/dist-tauri/index.html new file mode 100644 index 0000000..16c3de0 --- /dev/null +++ b/apps/web/dist-tauri/index.html @@ -0,0 +1,44 @@ + + +
+ + +Memuat ZeaVis Edu...
+ + diff --git a/apps/web/package.json b/apps/web/package.json index 47705bf..a66a693 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -12,6 +12,8 @@ "dependencies": { "@radix-ui/react-slot": "^1.2.4", "@tanstack/react-query": "^5.100.11", + "@tauri-apps/plugin-deep-link": "^2", + "@tauri-apps/plugin-opener": "^2", "@vitejs/plugin-react": "^6.0.2", "@zeavis/shared": "workspace:*", "class-variance-authority": "^0.7.1", diff --git a/apps/web/src/lib/tauri.ts b/apps/web/src/lib/tauri.ts index 29b54e7..2784868 100644 --- a/apps/web/src/lib/tauri.ts +++ b/apps/web/src/lib/tauri.ts @@ -29,32 +29,42 @@ export async function openUrl(url: string): Promise