In my Next.js 14 application using the App Router, I have encountered a peculiar issue with two API routes:
While both routes function properly when running locally, only one of them works after deploying to Vercel. The "/api/vision/describe-image/route.ts" route functions as expected, but the "/api/mini/describe-image/route.ts" route returns a 405 error.
Both routes contain a POST function and handle requests in a similar manner. The successful route processes image data using OpenAI's API, whereas the problematic route attempts to do the same.
The non-working route is being called as follows:
javascriptCopyconst response = await fetch("/api/mini/describe-image", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
message: "Image uploaded by user",
image: imageData,
conversation,
visitorId: user?.sub ?? visitorId,
conversationId,
}),
});
I have double-checked the file structure and ensured that a POST request is being sent. What could be the cause of this 405 error, and how can I go about troubleshooting it?
Any insights or suggestions?