From 45d36827d2cb87b7fd7feefe4db14c5284f86cf3 Mon Sep 17 00:00:00 2001 From: renee-png Date: Sat, 18 Jul 2026 18:04:18 -0400 Subject: [PATCH] Migrate backend from Lovable Cloud to own Supabase (EDU project) - Point .env + supabase/config.toml at EDU (qgmcpounpkgsjlwosjdi) - Replace Lovable Google-OAuth shim with native supabase.auth.signInWithOAuth - Remove src/integrations/lovable and @lovable.dev/cloud-auth-js dependency - Drop .lovable metadata; gitignore supabase/.temp Co-Authored-By: Claude Opus 4.8 --- .env | 12 +++++----- .gitignore | 4 ++++ .lovable/project.json | 5 ---- bun.lock | 3 --- package.json | 1 - src/integrations/lovable/index.ts | 38 ------------------------------- src/routeTree.gen.ts | 10 ++++++++ src/routes/auth.tsx | 12 ++++++---- supabase/config.toml | 2 +- 9 files changed, 29 insertions(+), 58 deletions(-) delete mode 100644 .lovable/project.json delete mode 100644 src/integrations/lovable/index.ts diff --git a/.env b/.env index cb0fa4c..d36213e 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ -SUPABASE_PROJECT_ID="fvjpfhfgkhgtwtzrgcgx" -SUPABASE_PUBLISHABLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZ2anBmaGZna2hndHd0enJnY2d4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODI4NDE0NDIsImV4cCI6MjA5ODQxNzQ0Mn0.B7dh8P2ZfUbJMtAGVbbRyyNFk71oqhJuqd0BNki-Dqk" -SUPABASE_URL="https://fvjpfhfgkhgtwtzrgcgx.supabase.co" -VITE_SUPABASE_PROJECT_ID="fvjpfhfgkhgtwtzrgcgx" -VITE_SUPABASE_PUBLISHABLE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZ2anBmaGZna2hndHd0enJnY2d4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3ODI4NDE0NDIsImV4cCI6MjA5ODQxNzQ0Mn0.B7dh8P2ZfUbJMtAGVbbRyyNFk71oqhJuqd0BNki-Dqk" -VITE_SUPABASE_URL="https://fvjpfhfgkhgtwtzrgcgx.supabase.co" +SUPABASE_PROJECT_ID="qgmcpounpkgsjlwosjdi" +SUPABASE_PUBLISHABLE_KEY="sb_publishable_NTbfdVFqAuqLls0rg6GFWA_vVcuIglp" +SUPABASE_URL="https://qgmcpounpkgsjlwosjdi.supabase.co" +VITE_SUPABASE_PROJECT_ID="qgmcpounpkgsjlwosjdi" +VITE_SUPABASE_PUBLISHABLE_KEY="sb_publishable_NTbfdVFqAuqLls0rg6GFWA_vVcuIglp" +VITE_SUPABASE_URL="https://qgmcpounpkgsjlwosjdi.supabase.co" diff --git a/.gitignore b/.gitignore index d24df8a..698a308 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,10 @@ lerna-debug.log* node_modules dist dist-ssr + +# Supabase CLI local state +supabase/.temp +supabase/.branches .output .vinxi .tanstack/** diff --git a/.lovable/project.json b/.lovable/project.json deleted file mode 100644 index f8be4ef..0000000 --- a/.lovable/project.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "schemaVersion": 1, - "template": "tanstack_start_ts_current", - "revision": "tanstack_start_ts_current-40f3c252c0da" -} diff --git a/bun.lock b/bun.lock index 9aab477..da6a1f7 100644 --- a/bun.lock +++ b/bun.lock @@ -6,7 +6,6 @@ "name": "tanstack_start_ts", "dependencies": { "@hookform/resolvers": "^5.2.2", - "@lovable.dev/cloud-auth-js": "^1.1.2", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-aspect-ratio": "^1.1.8", @@ -232,8 +231,6 @@ "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="], - "@lovable.dev/cloud-auth-js": ["@lovable.dev/cloud-auth-js@1.1.2", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/@lovable.dev/cloud-auth-js/-/cloud-auth-js-1.1.2.tgz", {}, "sha512-xz8ocewsgwkp8giau272/eWWU3XrchCg5uba4yQPPYtevHTXaVU3sD+fO1JjyPBHacVcOcwhmgUiU9TKHt63cg=="], - "@lovable.dev/vite-plugin-dev-server-bridge": ["@lovable.dev/vite-plugin-dev-server-bridge@1.0.2", "", { "peerDependencies": { "vite": ">=5.0.0 <9.0.0" } }, "sha512-1c4XLFkpS614VxPyq+IX0us52vm5JWxdO1NfG2L1FjH0asKvHNu5//6wpnKHWmx60Y4HR1gcLaIiLACXIdeFyg=="], "@lovable.dev/vite-plugin-hmr-gate": ["@lovable.dev/vite-plugin-hmr-gate@1.1.1", "https://europe-west1-npm.pkg.dev/lovable-core-prod/sandbox-npm-cache/@lovable.dev/vite-plugin-hmr-gate/-/vite-plugin-hmr-gate-1.1.1.tgz", { "peerDependencies": { "vite": ">=5.0.0 <9.0.0" } }, "sha512-ySRUzOoGQYhj4Pd9EjaA7i1+2RiaS5lSVZasun72wVZZmJfFIciGYGQQDUu88HISn4icz0sugQxFRJGCNlTggg=="], diff --git a/package.json b/package.json index ebcbff9..d1d0cd9 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ }, "dependencies": { "@hookform/resolvers": "^5.2.2", - "@lovable.dev/cloud-auth-js": "^1.1.2", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-aspect-ratio": "^1.1.8", diff --git a/src/integrations/lovable/index.ts b/src/integrations/lovable/index.ts deleted file mode 100644 index b677d42..0000000 --- a/src/integrations/lovable/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file is auto-generated by Lovable. Do not modify it. - -import { createLovableAuth } from "@lovable.dev/cloud-auth-js"; -import { supabase } from "../supabase/client"; -const lovableAuth = createLovableAuth(); - -type SignInOptions = { - redirect_uri?: string; - extraParams?: Record; -}; - -export const lovable = { - auth: { - signInWithOAuth: async (provider: "google" | "apple" | "microsoft" | "lovable", opts?: SignInOptions) => { - const result = await lovableAuth.signInWithOAuth(provider, { - redirect_uri: opts?.redirect_uri, - extraParams: { - ...opts?.extraParams, - }, - }); - - if (result.redirected) { - return result; - } - - if (result.error) { - return result; - } - - try { - await supabase.auth.setSession(result.tokens); - } catch (e) { - return { error: e instanceof Error ? e : new Error(String(e)) }; - } - return result; - }, - }, -}; diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 96f9928..b4cf9a0 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -307,3 +307,13 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() + +import type { getRouter } from './router.tsx' +import type { startInstance } from './start.ts' +declare module '@tanstack/react-start' { + interface Register { + ssr: true + router: Awaited> + config: Awaited> + } +} diff --git a/src/routes/auth.tsx b/src/routes/auth.tsx index 55a086c..672c299 100644 --- a/src/routes/auth.tsx +++ b/src/routes/auth.tsx @@ -2,7 +2,6 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { useState } from "react"; import { z } from "zod"; import { supabase } from "@/integrations/supabase/client"; -import { lovable } from "@/integrations/lovable"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -51,9 +50,14 @@ function AuthPage() { }; const onGoogle = async () => { - const res = await lovable.auth.signInWithOAuth("google", { redirect_uri: window.location.origin }); - if (res.error) toast.error(res.error.message ?? "Google sign-in failed"); - else if (!res.redirected) navigate({ to: "/dashboard" }); + // Native Supabase OAuth: redirects the browser to Google, then back to + // redirectTo. supabase-js (detectSessionInUrl) restores the session on + // return, and useAuth's onAuthStateChange picks it up. + const { error } = await supabase.auth.signInWithOAuth({ + provider: "google", + options: { redirectTo: `${window.location.origin}/dashboard` }, + }); + if (error) toast.error(error.message ?? "Google sign-in failed"); }; return ( diff --git a/supabase/config.toml b/supabase/config.toml index 24c1857..0e22c31 100644 --- a/supabase/config.toml +++ b/supabase/config.toml @@ -1 +1 @@ -project_id = "fvjpfhfgkhgtwtzrgcgx" \ No newline at end of file +project_id = "qgmcpounpkgsjlwosjdi"