From 9f0673b285de2fb4ddfceca0a86fe674171ecfa3 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com> Date: Sat, 2 Aug 2025 16:43:07 -0700 Subject: [PATCH] Remove process.env (#854) --- apps/sim/app/api/copilot/methods/route.ts | 3 ++- apps/sim/app/api/copilot/tools/other/online-search.ts | 3 ++- .../app/api/copilot/tools/user/set-environment-variables.ts | 3 ++- apps/sim/app/api/copilot/tools/workflow/build-workflow.ts | 5 +++-- apps/sim/app/api/copilot/tools/workflow/edit-workflow.ts | 5 +++-- apps/sim/app/api/copilot/tools/workflow/get-user-workflow.ts | 4 ---- apps/sim/lib/env.ts | 1 + 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/sim/app/api/copilot/methods/route.ts b/apps/sim/app/api/copilot/methods/route.ts index 7ff3e47a31..208f2b01d4 100644 --- a/apps/sim/app/api/copilot/methods/route.ts +++ b/apps/sim/app/api/copilot/methods/route.ts @@ -1,5 +1,6 @@ import { type NextRequest, NextResponse } from 'next/server' import { z } from 'zod' +import { env } from '@/lib/env' import { createLogger } from '@/lib/logs/console/logger' import { getRedisClient } from '@/lib/redis' import { copilotToolRegistry } from '../tools/registry' @@ -233,7 +234,7 @@ const MethodExecutionSchema = z.object({ // Simple internal API key authentication function checkInternalApiKey(req: NextRequest) { const apiKey = req.headers.get('x-api-key') - const expectedApiKey = process.env.INTERNAL_API_SECRET + const expectedApiKey = env.INTERNAL_API_SECRET if (!expectedApiKey) { return { success: false, error: 'Internal API key not configured' } diff --git a/apps/sim/app/api/copilot/tools/other/online-search.ts b/apps/sim/app/api/copilot/tools/other/online-search.ts index 9e75147765..6f15d33347 100644 --- a/apps/sim/app/api/copilot/tools/other/online-search.ts +++ b/apps/sim/app/api/copilot/tools/other/online-search.ts @@ -1,3 +1,4 @@ +import { env } from '@/lib/env' import { createLogger } from '@/lib/logs/console/logger' import { executeTool } from '@/tools' import { BaseCopilotTool } from '../base' @@ -49,7 +50,7 @@ async function onlineSearch(params: OnlineSearchParams): Promise