nitrojs / nitro

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

Nitro adds trailing slash at the end of devProxy target #2659

Open wokalek opened 2 months ago

wokalek commented 2 months ago

Environment


Reproduction

Set the settings from my settings described below and make sure that the proxy request is sent to the wrong url from nitro side.

Describe the bug

nuxt config:

nitro: {
  devProxy: {
    '/graphql': 'http://localhost:8000/graphql',
  },
},

The request from the browser goes to http://localhost:3000/graphql, but in the response I see (from Django) that the request came to http://localhost:3000/graphql/ and because my route on Django is set specifically to /graphql, it cannot be resolved.

I can add \/? to the expression on the backend side, but this is http://localhost:8000/graphql/ not what I wrote in the devProxy settings. This is a different url.

How to solve the problem? Or is it a bug?

Request in headers tab: image

Request preview (Django response): image Django logs: image

Additional context

No response

Logs

No response

wokalek commented 2 months ago

After deeping down inside nitro and httpxy, the following setting helped:

  '/graphql': { target: 'http://localhost:8000/graphql', prependPath: false },
wokalek commented 2 months ago

No, now it proxies requests to just http://localhost:8000. That's not what I need.