From 432e69f5f41bf8b3e4d4aa60a576a2ecc2299f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E8=B5=B7?= <50489191+esclipse@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:41:33 +0800 Subject: [PATCH] Remove hardcoded translate API key --- app/api/translate/route.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/api/translate/route.ts b/app/api/translate/route.ts index 21b3c59..31f70c7 100644 --- a/app/api/translate/route.ts +++ b/app/api/translate/route.ts @@ -1,13 +1,21 @@ import { NextResponse } from 'next/server'; import OpenAI from 'openai'; -const client = new OpenAI({ - apiKey: 'sk-rX3L6olaIfp2yYILAy1EWbgYI0bLebutNUJrrVKdeBLSlvJM', - baseURL: 'https://geekai.co/api/v1', -}); - export async function POST(request: Request) { try { + const apiKey = process.env.GEEKAI_API_KEY; + + if (!apiKey) { + return NextResponse.json( + { error: 'Missing translation API key' }, + { status: 500 } + ); + } + + const client = new OpenAI({ + apiKey, + baseURL: 'https://geekai.co/api/v1', + }); const { content, targetLanguage } = await request.json(); if (!content || !targetLanguage) {