{"id":22583,"library":"vite-plugin-auto-origin","title":"Vite Plugin Auto Origin","description":"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.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/s2b/vite-plugin-auto-origin","tags":["javascript","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-auto-origin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-auto-origin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-auto-origin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires Vite 5, 6, 7, or 8","package":"vite","optional":false}],"imports":[{"note":"Default export, ESM-only since v2. CommonJS require will fail.","wrong":"const autoOrigin = require('vite-plugin-auto-origin')","symbol":"autoOrigin","correct":"import autoOrigin from 'vite-plugin-auto-origin'"},{"note":"Type import for TypeScript users.","symbol":"AutoOriginOptions","correct":"import type { AutoOriginOptions } from 'vite-plugin-auto-origin'"},{"note":"autoOrigin is a factory function that returns a Vite Plugin object.","wrong":"const plugin = autoOrigin; (missing function call)","symbol":"Plugin","correct":"import type { Plugin } from 'vite'; import autoOrigin from 'vite-plugin-auto-origin'; const plugin: Plugin = autoOrigin()"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport autoOrigin from 'vite-plugin-auto-origin';\n\nexport default defineConfig({\n  plugins: [autoOrigin()],\n  // server.origin will be set automatically\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Use import/ESM syntax. If CJS is required, stick to v1.x.","message":"Version 2.0.0 drops CommonJS support. The package is ESM-only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Vite to ^5.0 || ^6.0 || ^7.0 || ^8.0","message":"Vite 5 is the minimum supported version in v2.x. Older Vite versions are not supported.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use vite-plugin-auto-origin@1.x for Vite 4, or upgrade Vite to 5+.","message":"The plugin does not work with Vite 4 or earlier. Ensure Vite version is compatible.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass options to autoOrigin({ origin: 'https://your-external-url' }) to force the origin.","message":"In some proxy configurations, the plugin may detect the internal proxy URL instead of the external URL. Manual override via options may be needed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to import statement or downgrade to v1.x.","cause":"Using CommonJS require() on an ESM-only package (v2+).","error":"require() of ES Module /node_modules/vite-plugin-auto-origin/dist/index.js from /project/vite.config.js not supported."},{"fix":"Use autoOrigin() (call the factory function) in the plugins array.","cause":"Calling autoOrigin as a value without parentheses, or importing incorrectly.","error":"TypeError: autoOrigin is not a function"},{"fix":"Upgrade Vite to ^5.0 || ^6.0 || ^7.0 || ^8.0 or install v1.x (npm install vite-plugin-auto-origin@1).","cause":"Installing v2.x with an older Vite version.","error":"Error: The plugin 'vite-plugin-auto-origin' requires Vite >=5.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}