3

I have a Nuxt3 app using server routes. The app works fine locally. However, after deployment to Vercel using vercel-edge preset, one of the routes for some reason is a 404.

When accessing this URL: https://modernmedtalk-dosstx.vercel.app/test and you try to send a chat message, the server returns the following error:

Error:

{
    "url": "/api/chat",
    "statusCode": 404,
    "statusMessage": "Cannot find any route matching /api/chat.",
    "message": "Cannot find any route matching /api/chat.",
    "stack": ""
}

No issues when running it locally. But on the remote server, the above error persists.

Anyone got any ideas why? Here is some more related context:

package.json:

  "scripts": {
    "build": "NITRO_PRESET=vercel-edge nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },

server/api/chat.post.js:

import { getChatStream } from '../utils/ai'

export default defineEventHandler(async (event) => {
  try {
    const { messages } = await readBody(event)
    console.log(1, messages)
    const stream = await getChatStream({ messages })
    return stream
    // return sendStream(event, stream)
  } catch (error) {
    console.error('error on server', error)
  }

})
redshift
  • 4,815
  • 13
  • 75
  • 138

0 Answers0