mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 20:28:04 +01:00
- Bump version to 0.1.1 for tracking - Add webpack-bundle-optimizer script for Next.js config - Simplify ESLint configuration to resolve missing dependencies - Prepare for production deployment with proper version control This deployment includes: - Profile update fixes with banner_url support - LN address validation - Auth cookie fixes for profile updates - Various documentation and testing improvements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1.9 KiB
1.9 KiB
Supabase Edge Functions
This directory contains Supabase Edge Functions to help with various aspects of the application.
CORS Proxy
The cors-proxy Edge Function is a solution to CORS issues when making authenticated requests to Supabase. It works by proxying requests through a serverless function that adds the proper CORS headers.
Why is this needed?
When making authenticated requests with credentials: 'include' mode, browsers require specific CORS headers from the server:
Access-Control-Allow-Origincannot be a wildcard (*) and must specify the exact originAccess-Control-Allow-Credentialsmust be set totrue
Some Supabase endpoints may respond with a wildcard, causing CORS errors.
How to deploy
-
Make sure you have the Supabase CLI installed:
npm install -g supabase -
Log in to Supabase CLI:
supabase login -
Deploy the function (from the project root):
./scripts/deploy-cors-proxy.shOr manually:
supabase functions deploy cors-proxy --project-ref your-project-ref -
Set the required environment variables:
supabase secrets set SUPABASE_URL="your-supabase-url" SUPABASE_ANON_KEY="your-supabase-anon-key" --project-ref your-project-ref -
Add the CORS proxy URL to your
.env.localfile:NEXT_PUBLIC_CORS_PROXY_URL=https://your-project-ref.supabase.co/functions/v1/cors-proxy
How it works
- Auth-related requests are detected in the Supabase client
- Instead of making the request directly to Supabase, the client redirects the request to the Edge Function
- The Edge Function makes the request to Supabase on behalf of the client
- The Edge Function adds the proper CORS headers to the response
- The response is returned to the client with the proper CORS headers
Testing
You can test the CORS proxy with:
curl -X GET "https://your-project-ref.supabase.co/functions/v1/cors-proxy?path=/rest/v1/health"