Skip to content

Regression in 7.1.0: different handling of server.proxy.*.target #20757

@wojtekmaj

Description

@wojtekmaj

Describe the bug

Upon upgrading from 7.0.6 to 7.1.0 the behavior of server.proxy.*.target has changed.

Here's a relevant part of my config file:

    server: {
      proxy: {
        '/api': {
          target: new URL('/api', 'http://localhost:3000'),
          secure: false,
          changeOrigin: true,
          xfwd: true,
        },
      },
    },

Until 7.0.6, this config resulted in http://localhost:5173/api/* calls proxied to http://localhost:3000/api/*.
From 7.1.0, this config results in calls proxied to http://localhost:3000/api/api*.

Server logs:

# 7.0.6
127.0.0.1 - [2025-09-12T07:05:45.706Z] "GET /api/users/current"
127.0.0.1 - [2025-09-12T07:05:45.737Z] "GET /api/config"
# 7.1.0
127.0.0.1 - [2025-09-12T07:06:01.959Z] "GET /api/api/users/current"
127.0.0.1 - [2025-09-12T07:06:01.984Z] "GET /api/api/config"

Reproduction

https://stackblitz.com/edit/vitejs-vite-utp6hhmk

Steps to reproduce

No response

System Info

Irrelevant - can be reproduced in stackblitz. But...

  System:
    OS: macOS 15.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 124.20 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.3.0 - /usr/local/bin/node
    Yarn: 4.9.1 - /usr/local/bin/yarn
    npm: 11.5.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 140.0.7339.133
    Safari: 18.6
  npmPackages:
    @vitejs/plugin-basic-ssl: ^2.1.0 => 2.1.0 
    @vitejs/plugin-react: ^5.0.0 => 5.0.0 
    vite: 7.1.0 => 7.1.0

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)regressionThe issue only appears after a new release

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions