Skip to content

schummar/vite-plugin-proxy-retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published