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.
npm install vite-plugin-reverse-proxy --save-dev
targets
- The target script to be proxied.preambleCode
- The preamble code to be injected before the main script.
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>