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

0.2.1 • Public • Published

vite-plugin-404-proxy

Vite plugin that proxies requests to a backend server when files are not found. Defaults to http://localhost:8080

// vite.config.ts
import proxyPlugin from "vite-plugin-404-proxy";

export default {
  plugins: [
    proxyPlugin()
  ]
}

Installation

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

Options

Short hand options are provided below:

Specify a port (host will be localhost)

// vite.config.ts
import proxyPlugin from "vite-plugin-404-proxy";

// Set to port 8080 (localhost)
export default {
  plugins: [
    proxyPlugin(8080)
  ]
}

Specify a target string

// vite.config.ts
import proxyPlugin from "vite-plugin-404-proxy";

export default {
  plugins: [
    proxyPlugin("http://localhost:8080")
  ]
}

Full http-proxy options

// Options object to vite-plugin-404-proxy will be supplied to http-proxy
const httpProxy = require("http-proxy");
const proxy = httpProxy.createProxyServer(options);
// vite.config.ts
import proxyPlugin from "vite-plugin-404-proxy";

export default {
  plugins: [
    proxyPlugin({
      target: {
        host: "localhost",
        port: 8080
      }
    })
  ]
}

License

MIT

Package Sidebar

Install

npm i vite-plugin-404-proxy

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

6.86 kB

Total Files

6

Last publish

Collaborators

  • tilleps