Conversation
…user and invalidateAll() Co-authored-by: acoyfellow <1666099+acoyfellow@users.noreply.github.com>
|
@copilot -- you need to write svelte5 syntax; import { page } from "$app/stores"; is depreciated. $syntax is depciated for runes. |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
…tores Co-authored-by: acoyfellow <1666099+acoyfellow@users.noreply.github.com>
Updated in 54c545a. Changed |
…ty and performance This commit updates several dependencies, including @sveltejs/kit, @tailwindcss/forms, alchemy, better-auth, drizzle-orm, and others, to their latest versions. Additionally, it enhances the create-remote-app template by updating its dependencies and adding basic styling to the app.css file.
… Auth This update modifies the `initAuth` function to accept a base URL, ensuring proper initialization for different environments. It also removes unused `getAuth` function and updates various files to reflect these changes, enhancing the overall structure and reliability of the authentication process.
| if (authBaseURL !== baseURL) { | ||
| throw new Error(`Auth already initialized for ${authBaseURL}, cannot re-init for ${baseURL}`); | ||
| } | ||
| return authInstance; |
There was a problem hiding this comment.
Bug: Auth singleton fails silently for multi-domain deployments
The auth singleton stores the baseURL from the first request's event.url.origin and throws an error if subsequent requests come from a different origin. In Cloudflare Workers, a single isolate can handle requests from multiple domains (e.g., custom domain AND workers.dev URL). When this happens, users accessing via the second domain will have their auth silently fail—the error is caught in hooks.server.ts and users are served as unauthenticated even if they have valid session cookies. The previous implementation used a fixed env.BETTER_AUTH_URL which avoided this issue. Consider using the environment variable as a fallback or making the baseURL check more permissive for configured trusted origins.
Remove duplicate client-side auth state management. Previously, auth state was synced from server (
hooks.server.ts→+layout.server.ts) into a client-sideauthStoreclass, creating potential sync bugs and unnecessary code.Changes
src/lib/auth-store.svelte.ts- Remove theAuthStoreclass and singleton+layout.svelte- No longer initializes auth store with server data+page.svelte- Usepage.data.userdirectly, call auth client methods inlineApplied same changes to
packages/create-remote-app/template/.New Pattern
~155 lines removed. Server remains single source of truth.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Note
Removes client auth store in favor of server-driven $page data with per-origin init, updates routes/layout and API, adds PR preview/prod Cloudflare deploy and cleanup, and bumps key dependencies with minor config/SEO tweaks.
authStore; make server the single source of truth via$page.data.user.initAuthto requirebaseURLand guard per-origin; dropgetAuthusage.src/routes/api/auth/[...all]/+server.tsand template equivalents to callinitAuth(db, env, event.url.origin).+layout.svelte(no store init).+page.svelteto callsignIn/signUp/signOutdirectly andinvalidateAll(); gate actions onpage.data.user.deploy_prod(push to main) anddeploy_preview(PR) with stagepr-${{ github.event.pull_request.number }}; updatecleanupto destroy matching stage.alchemy.run.ts: remove script/name fields; use defaultCloudflareStateStore; streamline D1/Worker/App setup (app + template).svelte.config.js: usealchemy()adapter in dev, Cloudflare adapter otherwise.src/app.html.app.css..gitignore: ignorepackage-lock.json.auth-store.svelte.tsfrom READMEs and project structure.@sveltejs/kit,svelte,tailwindcss,alchemy,better-auth,drizzle-*,vite,wrangler).Written by Cursor Bugbot for commit dcca06a. This will update automatically on new commits. Configure here.