tiny-cors-proxy
v1.0.6
Published
Cors Proxy
Downloads
32
Maintainers
Readme
tiny-cors-proxy
Fork from cors-everywhere in TypeScript
Table of content
- Description
- Installation
- Example 3.1 Proxy out of the box 3.2 Call it from everywhere 3.3 Configure your proxy 3.4 Rate limiter
- License
Description
This repository provides a tiny-cors-proxy to bypass cors
Installation
Run this command to install it
npm i tiny-cors-proxy
Example
Proxy out of the box
Easy use for tiny-cors-proxy
import corsServer from 'tiny-cors-proxy';
corsServer.listen(8080);
Use it from your favortie browser / server
Imagine that you want to call google.com from a page in your browser : do the following
const server = "http://localhost:8080";
const domain = "https://google.com"
const response = await fetch(`${server}/${domain}`, { headers: { 'x-requested-with': 'XMLHttpRequest' }} );
Configure it as you like
If you want to configure the server by your own
import { createServer } from 'tiny-cors-proxy';
const corsServer = createServer({
originWhitelist: [],
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2'],
});
corsServer.listen(8080);
More Option for your proxy server
If you want to add a rate limiter for and allowed
import { createServer, createRateLimitChecker } from 'tiny-cors-proxy';
const limiter = createRateLimitChecker('5 1'); // 5 request per minute
const corsServer = createServer({
originWhitelist: [], // Allow all origins
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2'],
checkRateLimit: limiter,
});
corsServer.listen(8080);