Update backend/src/routes/openai.js

This commit is contained in:
admin 2025-05-14 13:16:21 +00:00
parent e9d61a19ff
commit 85fe2843e0

View File

@ -224,8 +224,7 @@ router.post(
'/ask-gpt', '/ask-gpt',
wrapAsync(async (req, res) => { wrapAsync(async (req, res) => {
const { prompt } = req.body; const { prompt } = req.body;
const apiKey = req.body.apiKey || req.currentUser?.gpt_key; if (!prompt) {
if (!prompt || !apiKey) {
return res.status(400).send({ return res.status(400).send({
success: false, success: false,
error: 'Question and API key are required', error: 'Question and API key are required',