
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
vite-plugin-interceptor
Advanced tools
A vite plugin based on service worker to intercept and modify requests in a development environment
English | 中文
A vite plugin based on service worker to intercept and modify requests in a development environment
the browser needs to support service worker
a chrome extension can be used in production environment. easy-interceptor
npm i -D vite-plugin-interceptor
// in vite.config.ts
import interceptor from 'vite-plugin-interceptor'
export default defineConfig({
plugins: [
// interceptor()
// or
interceptor({
input: 'src/index.ts', // default src/main.ts
mockDir: '__mock__', // default mock
}),
]
})
// create a .ts or .js file in __mock__ dir, must use export default and set rules by plugin provide
export default function() {
window.__INTERCEPTOR_DEVTOOL__.set(
'1',
{
url: '**/tsconfig.json',
method: 'get',
response: '{"foo":"test"}',
// enable: false,
// delay: 5000,
}
)
}
ts type, create a file interceptor.d.ts, input this text
/// <reference types="vite-plugin-interceptor/typing" />
| prop | explain | type | description |
|---|---|---|---|
| get | get rules | ()=>Promise | |
| set | set a rule | (id, rule) => void | |
| clear | clear all rules | ()=>void |
| prop | explain | type | description |
|---|---|---|---|
| url | match request url | string | required |
| response | response text | string | required |
| delay | delay | number | 0 |
| enable | enable rule | boolean | true |
| method | request method | get post put delete | |
| responseHeaders | response headers | Record<string, string> | {} |
| status | response status | number | 200 |
perhaps, it has a warn in vite2.0, you can use
as any as Pluginto resolve it.
about multi-page: the sw.js scope is
./, so the plugin supports multi-page. just load the configured page to make the script active
FAQs
A vite plugin based on service worker to intercept and modify requests in a development environment
The npm package vite-plugin-interceptor receives a total of 1 weekly downloads. As such, vite-plugin-interceptor popularity was classified as not popular.
We found that vite-plugin-interceptor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.