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

1.0.2 • Public • Published

Adds a retry option to Vite's dev server proxy. This is useful when you're developing against a backend that takes a while to start up.

Installation

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

Usage

Enable retry with default options:

import { defineConfig } from "vite";
import vitePluginProxyRetry from "vite-plugin-proxy-retry";

export default defineConfig({
  plugins: [vitePluginProxyRetry()],

  server: {
    proxy: {
      "/api": {
        target: "http://localhost:8099",
        ws: true,
        retry: true,
      },
    },
  },
});

Specify options per proxy target:

import { defineConfig } from "vite";
import vitePluginProxyRetry from "vite-plugin-proxy-retry";

export default defineConfig({
  plugins: [vitePluginProxyRetry()],

  server: {
    proxy: {
      "/api": {
        target: "http://localhost:8099",
        ws: true,
        retry: {
          maxTries: 60,
          delay: 1000,
          maxDelay: 30_000,
          backoff: false,
        },
      },
    },
  },
});

Specify options globally:

import { defineConfig } from "vite";
import vitePluginProxyRetry from "vite-plugin-proxy-retry";

export default defineConfig({
  plugins: [
    vitePluginProxyRetry({
      maxTries: 60,
      delay: 1000,
      maxDelay: 30_000,
      backoff: false,
    }),
  ],

  server: {
    proxy: {
      "/api": {
        target: "http://localhost:8099",
        ws: true,
      },
    },
  },
});

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-proxy-retry

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

10.4 kB

Total Files

5

Last publish

Collaborators

  • schummar