fix: corrigindo CORS Headers
Some checks are pending
Docker Build and Push / build (push) Waiting to run

This commit is contained in:
Lucas Santana 2025-01-19 10:31:52 -03:00
parent 0c2a63dcd3
commit 198cad0047
3 changed files with 7 additions and 3 deletions

View File

@ -6,6 +6,8 @@ const nextConfig = {
'oaidalleapiprodscus.blob.core.windows.net', 'oaidalleapiprodscus.blob.core.windows.net',
'leiturama.ai', 'leiturama.ai',
'localhost', 'localhost',
'bsjlbnyslxzsdwxvkaap.supabase.co',
'leiturama.netlify.app'
], ],
formats: ['image/avif', 'image/webp'], formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 60, minimumCacheTTL: 60,

View File

@ -20,7 +20,7 @@ export const generateStoryFunction = async (prompt: StoryPrompt) => {
const { data: { session } } = await supabase.auth.getSession() const { data: { session } } = await supabase.auth.getSession()
const response = await fetch( const response = await fetch(
'https://seu-project-ref.supabase.co/functions/v1/generate-story', 'https://bsjlbnyslxzsdwxvkaap.supabase.co/functions/v1/generate-story',
{ {
method: 'POST', method: 'POST',
headers: { headers: {

View File

@ -18,7 +18,8 @@ interface StoryPrompt {
const ALLOWED_ORIGINS = [ const ALLOWED_ORIGINS = [
'http://localhost:5173', // Vite dev server 'http://localhost:5173', // Vite dev server
'http://localhost:3000', // Caso use outro port 'http://localhost:3000', // Caso use outro port
'https://leiturama.ai' // Produção 'https://leiturama.ai', // Produção
'https://leiturama.netlify.app'
]; ];
interface StoryResponse { interface StoryResponse {
@ -48,9 +49,10 @@ serve(async (req) => {
const corsHeaders = { const corsHeaders = {
'Cross-Origin-Resource-Policy': 'cross-origin', 'Cross-Origin-Resource-Policy': 'cross-origin',
'Access-Control-Allow-Origin': ALLOWED_ORIGINS.includes(origin) ? origin : ALLOWED_ORIGINS[0], 'Access-Control-Allow-Origin': ALLOWED_ORIGINS.includes(origin) ? origin : ALLOWED_ORIGINS[0],
'Access-Control-Allow-Methods': 'POST, OPTIONS', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT, DELETE',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
'Access-Control-Max-Age': '86400', // 24 horas 'Access-Control-Max-Age': '86400', // 24 horas
'Cross-Origin-Embedder-Policy': 'credentialless'
}; };
// Preflight request // Preflight request