0.2.1 • Published 1 year ago

vite-plugin-404-proxy v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

0.2.1

1 year ago

0.2.0

1 year ago

0.1.4

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago