`@chenshunyu/proxy` is a lightweight HTTP proxy server designed to help developers easily modify HTTP request headers for testing and debugging network requests.
@chenshunyu/proxy is a lightweight HTTP proxy server designed to help developers easily modify HTTP request headers for testing and debugging network requests.
@chenshunyu/proxy via npm:bash
npm i @chenshunyu/proxy
`Usage
Start the proxy server:
`bash
node node_modules/@chenshunyu/proxy --port 8080 --file headers.txt
`$3
- --port: Specifies the port number the proxy server listens on. Default is 8080.- --file: Specifies the path to the file containing request header information. The file format should be key-value pairs, one per line, for example:
`
GET /example/path HTTP/1.1
key1: value1
key2: value2
`$3
1. Open the browser developer tools (usually by pressing F12 or right-clicking and selecting "Inspect").
1. Go to the "Network" tab.
1. Right-click any request and select "Copy" -> "Copy request headers".
!help
1. Paste the copied content into a text file and save it as headers.txt.$3
When a request expires, you can continue using the proxy service by updating the headers.txt file.$3
For security purposes, it's strongly recommended to add headers.txt to your .gitignore/.npmignore files. This prevents accidental exposure of sensitive headers (like cookies or tokens) in version control systems.Example
.gitignore entry:
`diff
+ # Ignore proxy header files
+ headers.txt
`Example
Assume you have a file named headers.txt with the following content:`
GET /example/path HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Accept-Language: en-US,en;q=0.9
Cookie: session=abc123; user=JohnDoe
Host: example.com
Referer: https://example.com/login
X-CSRF-TOKEN: abcdef123456
`Start the proxy server:
`bash
node node_modules/@chenshunyu/proxy --port 8080 --file headers.txt
`Now, the proxy server will run on port 8080 and use the request header information from the
headers.txt file. If the request expires, update the headers.txt` file.