Skip to content

Latest commit

 

History

History
83 lines (68 loc) · 1.44 KB

README.md

File metadata and controls

83 lines (68 loc) · 1.44 KB

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,
      },
    },
  },
});