Cors Proxy
npm install tiny-cors-proxy
npm i tiny-cors-proxy
`
Example
$3
Easy use for tiny-cors-proxy
`js
import corsServer from 'tiny-cors-proxy';
corsServer.listen(8080);
`
$3
Imagine that you want to call google.com from a page in your browser : do the following
`js
const server = "http://localhost:8080";
const domain = "https://google.com"
const response = await fetch(${server}/${domain}, { headers: { 'x-requested-with': 'XMLHttpRequest' }} );
`
$3
If you want to configure the server by your own
`js
import { createServer } from 'tiny-cors-proxy';
const corsServer = createServer({
originWhitelist: [],
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2'],
});
corsServer.listen(8080);
`
$3
If you want to add a rate limiter for and allowed
`js
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);
``