Skip to content

Latest commit

 

History

History

vite-plugin-reverse-proxy

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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