nitrojs / nitrojs/nitro

`baseURL` is not replaced when forwarding proxy #2708

Open
#3,424 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

Nitro v2

Reproduction

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

Describe the bug

With a baseURL + proxy, the base is included in the proxied request:

export default defineNitroConfig({
  baseURL: '/app',
  routeRules: {
    '/api/v1/**': { proxy: { to: 'https://dummyjson.com/**' } },
  },
});

So /app/api/v1/quotes/random does not correctly proxy to http://dummyjson.com/quotes/random.

previously reported without a reproduction in https://github.com/nitrojs/nitro/issues/2708

Additional context

No response

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and the Nitro configuration using baseURL and routeRules proxy. Trace the proxy request handling to determine where the baseURL remains in the forwarded path, then verify that /app/api/v1/quotes/random forwards to the intended upstream path without the base prefix.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.