unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

routeRules proxy error #2615

Open ZenoHu opened 2 months ago

ZenoHu commented 2 months ago

Environment

mac

Reproduction

https://codesandbox.io/p/devbox/pensive-poitras-3xsl4r?embed=1&file=%2Fserver%2Fapi%2Fv1%2Fupload.post.ts

Describe the bug

  1. in nuxt.config.ts
    routeRules: {
    "/proxy/**": {
      proxy: {
        to: "/api/v1/**",
      },
    },
    },
  2. in upload.post.ts
    
    import { IncomingForm } from "formidable";

export default defineEventHandler(async (event) => { event.node.req.on("data", (chunk) => { // will not log when submit to /proxy/upload console.log("data received", chunk); });

const form = new IncomingForm({ uploadDir: "./upload" });

form.parse(event.node.req, (_, __, files) => { // will not log when submit to /proxy/upload console.log(files); });

return "success"; });



### Additional context

_No response_

### Logs

_No response_