A Vite plugin that automatically configures server.origin to the external URL of the Vite dev server, essential for backend integration scenarios where assets (images, fonts) must be loaded from the dev server URL rather than the backend. Version 2.0.2 supports Vite 5+, ships TypeScript types, and is ESM-only since v2. Active maintenance with frequent updates aligned with Vite major releases. Differentiator: handles proxy chains automatically without manual configuration.
npm install vite-plugin-auto-originVerified import paths — ran on the pinned version, not inferred.
Install the plugin and add it to the Vite config. The server.origin will be automatically set to the external URL of the dev server.
Use import/ESM syntax. If CJS is required, stick to v1.x.
Upgrade Vite to ^5.0 || ^6.0 || ^7.0 || ^8.0
Use vite-plugin-auto-origin@1.x for Vite 4, or upgrade Vite to 5+.
Pass options to autoOrigin({ origin: 'https://your-external-url' }) to force the origin.Change to import statement or downgrade to v1.x.
Use autoOrigin() (call the factory function) in the plugins array.
Upgrade Vite to ^5.0 || ^6.0 || ^7.0 || ^8.0 or install v1.x (npm install vite-plugin-auto-origin@1).