vite-plugin-reverse-proxy
v4.0.5
Published
Makes the script to be served with the text/javascript MIME type instead of module MIME type.
Downloads
6
Maintainers
Readme
vite-plugin-reverse-proxy
Makes the script to be served with the text/javascript MIME type instead of module MIME type. Vite >= 3.1
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>