1.0.2 • Published 2 years ago

vite-plugin-proxy-retry v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago