Vite-Shield is a zero-configuration CLI tool that automatically adds comprehensive security headers to Vite/React projects. Version 1.0.0 integrates security headers into Vite's dev and preview servers, generates a production-ready Express.js server with helmet-style headers, and creates an Nginx configuration template. Unlike manual header setup or using helmet separately, Vite-Shield provides a one-command solution using AST-based transformations to safely modify vite.config.ts/js without breaking existing setups. It applies headers like Strict-Transport-Security, CSP, X-Frame-Options, and more across all environments.
npm install vite-shieldVerified import paths — ran on the pinned version, not inferred.
Shows how to install and run vite-shield via global install or npx, then start the generated Express server.
Manually back up your vite.config before running vite-shield
Review the generated config and manually adjust if needed
Add "type": "module" to package.json or rename server.js to server.mjs
Ensure the add_header directives are inside the server block and not duplicated
Use npx vite-shield or npm install -g vite-shield
cd to the directory containing vite.config.ts or vite.config.js before running
Run vite-shield with no arguments