diff --git a/apps/sim/app/api/workflows/[id]/execute/route.ts b/apps/sim/app/api/workflows/[id]/execute/route.ts index c111103c7e..5ad00fc1a3 100644 --- a/apps/sim/app/api/workflows/[id]/execute/route.ts +++ b/apps/sim/app/api/workflows/[id]/execute/route.ts @@ -1,4 +1,4 @@ -import { NextRequest } from 'next/server' +import { NextRequest, NextResponse } from 'next/server' import { eq, sql } from 'drizzle-orm' import { v4 as uuidv4 } from 'uuid' import { z } from 'zod' @@ -367,3 +367,16 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{ ) } } + +export async function OPTIONS(request: NextRequest) { + return new NextResponse(null, { + status: 200, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', + 'Access-Control-Allow-Headers': + 'Content-Type, X-API-Key, X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Date, X-Api-Version', + 'Access-Control-Max-Age': '86400', + }, + }) +} diff --git a/apps/sim/next.config.ts b/apps/sim/next.config.ts index 465bd4f74c..410b4930a4 100644 --- a/apps/sim/next.config.ts +++ b/apps/sim/next.config.ts @@ -77,7 +77,26 @@ const nextConfig: NextConfig = { { key: 'Access-Control-Allow-Headers', value: - 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version', + 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-API-Key', + }, + ], + }, + // For workflow execution API endpoints + { + source: '/api/workflows/:id/execute', + headers: [ + { key: 'Access-Control-Allow-Origin', value: '*' }, + { key: 'Access-Control-Allow-Methods', value: 'GET,POST,OPTIONS,PUT' }, + { + key: 'Access-Control-Allow-Headers', + value: + 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-API-Key', + }, + { key: 'Cross-Origin-Embedder-Policy', value: 'unsafe-none' }, + { key: 'Cross-Origin-Opener-Policy', value: 'unsafe-none' }, + { + key: 'Content-Security-Policy', + value: "default-src * 'unsafe-inline' 'unsafe-eval'; connect-src *;", }, ], },