Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lisonge/vite-plugin-switch-hosts
switch hosts by service worker for each origin in browser without modify system hosts file
https://github.com/lisonge/vite-plugin-switch-hosts
host hosts vite vite-plugin
Last synced: about 1 month ago
JSON representation
switch hosts by service worker for each origin in browser without modify system hosts file
- Host: GitHub
- URL: https://github.com/lisonge/vite-plugin-switch-hosts
- Owner: lisonge
- Created: 2022-03-18T07:36:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-28T04:18:18.000Z (over 2 years ago)
- Last Synced: 2024-04-25T10:41:04.623Z (7 months ago)
- Topics: host, hosts, vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 80.1 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# vite-plugin-switch-hosts
switch hosts by service worker for each origin in browser without modify system hosts file
## feature
- switch hosts
- different origin can use different hosts simultaneously
- without modify system hosts file## limitation
- current origin must support [service worker](https://developer.mozilla.org/docs/Web/API/Service_Worker_API). in other words, `location.hostname` is `localhost` or match `127.x.y.z`, or `location.protocol` must be `https:`
- target domain must use http or https, websocket is not supported
- redirect url will follow in proxy dev server, not found a better solution yet
## install
```shell
pnpm add -D vite-plugin-switch-hosts
```## config
[SwitchHostsOption](./src/index.ts#L17)
```ts
export interface SwitchHostsOption {
/**
* host -> another_host
*/
dns?: Record;
}
```## example
see [test/example/vite.config.ts](./test/example/vite.config.ts)