fix: Resolve Supabase SSR cookie handling and auth test page issues
- Add null checks for cookies object in Supabase SSR client - Fix auth test page to use Astro.cookies instead of Astro.request - Prevent "Cannot read properties of undefined" errors in cookie handling - Ensure proper unified auth usage pattern in test pages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,12 +12,15 @@ export function createSupabaseServerClient(
|
|||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
|
if (!cookies) return undefined;
|
||||||
return cookies.get(name)?.value
|
return cookies.get(name)?.value
|
||||||
},
|
},
|
||||||
set(name: string, value: string, options: CookieOptions) {
|
set(name: string, value: string, options: CookieOptions) {
|
||||||
|
if (!cookies) return;
|
||||||
cookies.set(name, value, options)
|
cookies.set(name, value, options)
|
||||||
},
|
},
|
||||||
remove(name: string, options: CookieOptions) {
|
remove(name: string, options: CookieOptions) {
|
||||||
|
if (!cookies) return;
|
||||||
cookies.delete(name, options)
|
cookies.delete(name, options)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ let cookies = null;
|
|||||||
let headers = null;
|
let headers = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Test unified auth
|
// Test unified auth - use Astro.cookies for pages
|
||||||
auth = await verifyAuth(Astro.request);
|
auth = await verifyAuth(Astro.cookies);
|
||||||
|
|
||||||
// Capture debug info
|
// Capture debug info
|
||||||
cookies = Astro.request.headers.get('Cookie') || 'No cookies';
|
cookies = Astro.request.headers.get('Cookie') || 'No cookies';
|
||||||
|
|||||||
Reference in New Issue
Block a user