-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Open
Labels
Description
Describe the bug
When vite server.proxy is configured with auth
option, I'm expecting basic authentication Auhorization: Basic ${Buffer.from('user:pass').toString('base64')}
header to be sent to the upstream, and it is, unless the client sends own authorization header.
It's bug in http-proxy
But since it's patched using pnpm and bundled within vite either this has to be patched as well, or probably a fork of http-proxy can be made within vitejs
Reproduction
https://stackblitz.com/edit/vitejs-vite-cppgeu2m?file=src%2Fcounter.js,src%2Fmain.js,vite.config.js
Steps to reproduce
configure proxy
const proxy = {
'/api/service1': {
target: 'http://localhost:80/endpoint/requiring/basic-auth',
auth: 'user1:pass1',
},
};
export default defineConfig({
server: {
proxy,
},
});
fetch('/api/service1', { headers: { authorization: "anything" } })
### System Info
```shell
not relevant
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.