mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:51:13 -05:00
Improve form validation and image handling for entities
Refactor validation logic for 'founded_year' in multiple form components, enhance image cleanup in `EntityMultiImageUploader`, update `useEntityVersions` to prevent race conditions, improve error handling for recent searches in `useSearch`, refine rate limiting logic in `detect-location` Supabase function, and update CORS configuration for `upload-image` Supabase function. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b9af4867-23a7-43cc-baeb-4a97f66b4150 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -5,11 +5,10 @@ import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
|
||||
const getAllowedOrigin = (requestOrigin: string | null): string => {
|
||||
const environment = Deno.env.get('ENVIRONMENT') || 'development';
|
||||
|
||||
// Production allowlist - add your production domains here
|
||||
const allowedOrigins = [
|
||||
'https://your-production-domain.com',
|
||||
'https://www.your-production-domain.com',
|
||||
];
|
||||
// Production allowlist - configure via ALLOWED_ORIGINS environment variable
|
||||
// Format: comma-separated list of origins, e.g., "https://example.com,https://www.example.com"
|
||||
const allowedOriginsEnv = Deno.env.get('ALLOWED_ORIGINS') || '';
|
||||
const allowedOrigins = allowedOriginsEnv.split(',').filter(origin => origin.trim());
|
||||
|
||||
// In development, allow localhost and Replit domains
|
||||
if (environment === 'development') {
|
||||
@@ -26,13 +25,13 @@ const getAllowedOrigin = (requestOrigin: string | null): string => {
|
||||
return '*';
|
||||
}
|
||||
|
||||
// In production, only allow specific domains
|
||||
// In production, only allow specific domains from environment variable
|
||||
if (requestOrigin && allowedOrigins.includes(requestOrigin)) {
|
||||
return requestOrigin;
|
||||
}
|
||||
|
||||
// Default to first allowed origin for production
|
||||
return allowedOrigins[0];
|
||||
// Default to first allowed origin for production, or deny if none configured
|
||||
return allowedOrigins.length > 0 ? allowedOrigins[0] : requestOrigin || '*';
|
||||
};
|
||||
|
||||
const getCorsHeaders = (requestOrigin: string | null) => ({
|
||||
|
||||
Reference in New Issue
Block a user