I tried to connect via basic auth to a URL using vite. Credentials are correct, but an empty form field opens up.
export default defineConfig({
base: './',
server: {
proxy: {
'/data': {
target: 'https://user:[email protected]/foo',
changeOrigin: true,
}
},
}});
Sadly this is not working - here I found a related question 
CodePudding user response:
Vite server proxy is a http-proxy (https://www.npmjs.com/package/http-proxy). Therefor the same config settings can be applied.
export default defineConfig({
base: './',
server: {
proxy: {
'/data': {
target: 'https://example.com/foo',
changeOrigin: true,
configure: (proxy, options) => {
// proxy will be an instance of 'http-proxy'
const username = 'username';
const password = 'password';
options.auth = `${username}:${password}`;
},
}
},
},
})
