Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to the server.proxy in the plugin API configureServer did not take effect #18056

Closed
7 tasks done
heggria opened this issue Sep 9, 2024 · 2 comments
Closed
7 tasks done

Comments

@heggria
Copy link

heggria commented Sep 9, 2024

Describe the bug

I tried writing a plugin to switch server.proxy in the development environment for dynamically changing the proxy, but it didn't seem to actually switch during runtime. I tested switching other configurations of the server, such as server.port, and they worked fine.

Reproduction

https://stackblitz.com/edit/vitejs-vite-mqmnh4?file=vite-plugin-proxy-switch.ts

Steps to reproduce

Clicking the button at the bottom right of the preview switches the server.proxy configuration, and clicking the count button triggers a fetch request. By checking the request domain and the identifier in the request headers in the console, you can see that the server.proxy configuration switch did not take effect. However, directly modifying the useFirstProxy variable in the code allows the switch to work as expected.

System Info

System:
    OS: macOS 14.4
    CPU: (8) arm64 Apple M3
    Memory: 79.53 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.4/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm
    pnpm: 9.7.0 - ~/.nvm/versions/node/v18.20.4/bin/pnpm
  Browsers:
    Chrome: 128.0.6613.120
    Safari: 17.4

Used Package Manager

pnpm

Logs

No response

Validations

Copy link

stackblitz bot commented Sep 9, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red
Copy link
Member

We don't support modifying the ResolvedConfig.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants