Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/api/creative-chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { NextResponse } from 'next/server';
import OpenAI from 'openai';

const DEFAULT_API_KEY = 'sk-rX3L6olaIfp2yYILAy1EWbgYI0bLebutNUJrrVKdeBLSlvJM';
const DEFAULT_BASE_URL = 'https://geekai.co/api/v1';
const DEFAULT_MODEL = 'qwen-turbo';
const DEFAULT_API_KEY =
process.env.OPENAI_API_KEY || 'sk-2893a75c1cfd407aa601eab503ad918a';
Comment on lines +4 to +5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove hard-coded API key default

The server route embeds a literal API key as the fallback for DEFAULT_API_KEY. If this code is shipped or shared, that credential is exposed to anyone with repo or bundle access and can be abused for unauthorized API usage and billing. This should instead require an environment-provided key (and fail fast when missing) or use a non-secret placeholder that never leaves development.

Useful? React with 👍 / 👎.

const DEFAULT_BASE_URL =
process.env.OPENAI_BASE_URL ||
'https://dashscope.aliyuncs.com/compatible-mode/v1';
const DEFAULT_MODEL = process.env.OPENAI_MODEL || 'qwen3-plus';
const SYSTEM_PROMPT =
'你是内容创作助手,请根据用户需求输出适合富文本编辑器的 HTML 片段。' +
'输出仅包含正文内容,不要包含 markdown 代码块、标题之外的说明或外层 HTML/Body 标签。';
Expand Down