The NGO App's AI Worked Locally. Then Vercel Gave Me a 504.
I was testing the AI assistant locally, and everything was working. Then I deployed it. I opened the production app and asked: "how start meditation. im a beginner". Instead of an answer, I got: Unexpected token 'A', "An error o"... is not valid JSON.
At first, I thought I had broken something in the frontend. I hadn't. The error was hiding the actual problem. I checked the browser Network tab. The request was: POST /api/ai/chat and the response was: 504 Gateway Timeout.
So the JSON error wasn't the actual problem. The frontend was trying to parse an error response as JSON, while the request itself had already timed out. That changed my debugging path. Instead of looking at the JSON parser, I needed to find out why the server request was timing out.
But It Worked Locally
This was the confusing part. The same AI request worked on my local machine. The local terminal showed:
POST /api/ai/chat 200 in 21994ms
The logs showed: AI context retrieved, model: openai/gpt-5-mini. The AI completion itself took around 17.76 seconds. The usage was:
- `prompt
Comments
No comments yet. Start the discussion.