nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Vercel preset + edge middleware , sets 404 to /api/* endpoints

Open Yegaston opened this issue 1 year ago • 0 comments

Environment

Operating System: macOs 12.5.1 (21G83) Node Version: v16.11.1 Nuxt Version: 3.0.0-rc.6 Package Manager: [email protected] Builder: vite

Reproduction

https://stackblitz.com/edit/github-usfnbu

Describe the bug

If a middleware.ts file is created in the root of the project to use vercel's edge middleware, the config.json file that nitro generates sends to 404 to all /api/* endpoints For example:

{
  "version": 3,
  "routes": [
    {
      "src": "/_nuxt(.*)",
      "headers": {
        "cache-control": "public,max-age=31536000,immutable"
      },
      "continue": true
    },
    {
      "handle": "error"
    },
    {
      "status": 404,
      "src": "^(?!/api).*$",
      "dest": "/404.html"
    },
    {
      "handle": "filesystem"
    },
    {
      "src": "/(.*)",
      "dest": "/"
    }
  ]
}

But if not have that middleware.ts file, the build not generates this exeception to api endpoints

Additional context

No response

Logs

No response

Yegaston avatar Sep 06 '22 14:09 Yegaston