Socket
Book a DemoInstallSign in
Socket

vite-plugin-allowed-hosts

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-allowed-hosts

List hosts allowed to access Vite dev server

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Vite Allowed Hosts

Build Status Version Downloads

Specify a list of hosts that are allowed to access your Vite dev server.

Motivation

By rejecting requests with an unrecognized Host header, this plugin prevents DNS rebinding attacks, which are possible even under many seemingly-safe web server configurations.

In a DNS rebinding attack, an attacker can create a malicious website that makes requests to the development server using the victim’s browser, potentially gaining access to sensitive data or executing unauthorized actions.

Usage

// vite.config.js
import pluginAllowedHosts from "vite-plugin-allowed-hosts";

export default {
  plugins: [
    pluginAllowedHosts({
      hosts: ["acme.com", ".dev.acme.com"]
    })
  ]
}

Options

hosts

  • Type: 'auto' | 'all' | string | string[]

  • Default: 'auto'

    When set to 'auto', it will always allow localhost and [server.host](https://vitejs.dev/config/server-options.html#server-host).

    When set to 'all', no header check will be done. This is obviously not recommended.

    A value beginning with a period . can be used as a subdomain wildcard. For example, '.acme.com' will match acme.com, www.acme.com, and any other subdomain of acme.com.

    If the Host header doesn't match any value in this list, a 403 Forbidden HTTP error will be returned.

License

vite-plugin-allowed-hosts is released under the MIT License. See the bundled LICENSE file for details.

Keywords

vite

FAQs

Package last updated on 16 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts