vite-plugin-http-basic-auth
v1.0.2
Published
A Vite plugin adding HTTP Basic Auth support
Downloads
447
Readme
vite-plugin-http-basic-auth
- HTTP basic auth for vite server
Install
npm i -D vite-plugin-http-basic-auth
Example usage
import { defineConfig, loadEnv } from 'vite'
import httpAuth from 'vite-plugin-http-basic-auth'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return ({
plugins: [
httpAuth([{
username: env.VITE_AUTH_USERNAME_1,
password: env.VITE_AUTH_PASSWORD_1
},{
username: env.VITE_AUTH_USERNAME_2,
password: env.VITE_AUTH_PASSWORD_2
}], {
realm: env.VITE_AUTH_REALM,
useInServer: true, // True by default
useInPreview: true, // True by default
})
]
})
})