0.7.7 • Published 6 months ago

@open-xchange/vite-plugin-proxy v0.7.7

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

@open-xchange/vite-plugin-proxy

An OX App Suite specific proxy for development purposes. Can connect multiple vite-dev-servers with @open-xchange/vite-plugin-ox-manifests plugins.

Install

npm install "@open-xchange/vite-plugin-proxy"
yarn add "@open-xchange/vite-plugin-proxy"

Options

You can provide the following options to the plugin:

proxy

An object with reverse proxy configurations, where the keys need to match the beginning of the path. Usually used to forward /api requests to a backend.

  • proxykey <string> The key defines which paths should be proxied. Keys starting with ^ will be treated as regular expressions.
  • proxykey.target <string> The target where to forward these requests to.
  • proxykey.ws <boolean> If ws is true, this will only listen to upgrade events for a websocket. Default: false
  • proxykey.rewrite <function> A function that receives the path as parameter and returns the new path to proxy.
  • proxykey.prependPath <string> A string that is prepended for every request. If prependPath and rewrite are present, the key is first prepended and then rewrite is called.
  • proxykey.changeOrigin <boolean> Changes the origin of the host header to the target URL. Default: false
  • proxykey.secure <boolean> Set to false to allow self-signed certificates. Default: true

frontends

An array of objects with frontends to proxy to. A frontend is defined as a server with UI-files and a /manifest endpoint. Every vite-dev server with the @open-xchange/vite-plugin-manifest plugin fullfills this requirement. This plugin will always add the current vite-dev server as the first entry into this array such that serving files from the local machine has always the highest priority.

  • frontendsi.target <string> The target, where to forward requests to.
  • frontendsi.path <string> Optional parameter which will prioritize this frontend for the given path. Is like a reverse proxy configuration for frontends. To indicate a regexp, start the string with a ^.
  • frontendsi.secure <boolean> Set to false to allow self-signed certificates. Default: true

httpProxy

An object for a http proxy to be ususally used with tools like Switchy Omega

  • httpProxy.target <string> The domain which is handled by the vite proxy. You need to make sure, that the proxy configuration is set accordingly.
  • httpProxy.port <number> The port on which the httpProxy server will listen for requests. Default 8080

logLevel

One of fatal, error, warn, info, debug, trace, silent. Default: warn

Example configuration

vitePluginProxy({
  proxy: {
    '/api': {
      target: 'https://path.to.my.middleware/',
      prependPath: '/appsuite',
      rewrite: path => path.replace(/\/v1\//, '/v2/'),
      changeOrigin: true
    },
    '/socket.io/appsuite': {
      target: `wss://path.to.my.middleware/socket.io/appsuite`,
      ws: true,
      changeOrigin: true,
      secure: false
    }
  },
  frontends: [{
    target: 'https://localhost:3000',
    path: '/io.ox/guidedtours',
    secure: false
  }, {
    target: 'https://localhost:3001',
    path: '/io.ox/customplugin',
  }],
  logLevel: 'info'
}),
0.7.7

6 months ago

0.7.6

7 months ago

0.7.5

10 months ago

0.7.2

11 months ago

0.7.4

11 months ago

0.7.3

11 months ago

0.7.1

11 months ago

0.7.0

11 months ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.5.2

1 year ago

0.6.0

1 year ago

0.5.1

2 years ago

0.5.0-pre1

2 years ago

0.5.0

2 years ago

0.4.4

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.0-pre4

3 years ago

0.2.0-pre3

3 years ago

0.2.0-pre2

3 years ago

0.2.0-pre1

3 years ago

0.1.1-pre2

3 years ago

0.1.1-pre1

3 years ago

0.1.0

3 years ago

0.1.0-pre1

3 years ago