vite-plugin-reverse-proxy
TypeScript icon, indicating that this package has built-in type declarations

4.0.5 • Public • Published

vite-plugin-reverse-proxy

npm package

Makes the script to be served with the text/javascript MIME type instead of module MIME type. Vite >= 3.1

NPM version NPM Downloads

Sometimes we have to redirect scripts on production environment to debug and solve problems, the plugin will transform the script to be served with the text/javascript MIME type to module MIME type.

Installation

npm install vite-plugin-reverse-proxy --save-dev

Options

  • targets - The target script to be proxied.
  • preambleCode - The preamble code to be injected before the main script.

Usage

Define a proxy configuration on XSwitch

{
  "proxy": [
    [
      "http(s)?://(.*)/xxx/assets/main.js",
      "http://localhost:3000/app.js"
    ]
  ]
}

Use 'vite-plugin-reverse-proxy' to define proxy rules for web development

import { defineConfig } from 'vite';
import reverseProxy from 'vite-plugin-reverse-proxy';

export default defineConfig({
  plugins: [
    reverseProxy({
      targets: {
        '/app.js':'src/main.jsx'
      }
    }),
  ]
});
<script src="/app.js"></script>

Examples

Package Sidebar

Install

npm i vite-plugin-reverse-proxy

Weekly Downloads

3

Version

4.0.5

License

MIT

Unpacked Size

12 kB

Total Files

9

Last publish

Collaborators

  • fengxinming