tiny-cors-proxy
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

tiny-cors-proxy

Fork from cors-everywhere in TypeScript MIT license image

Table of content

  1. Description
  2. Installation
  3. Example 3.1 Proxy out of the box 3.2 Call it from everywhere 3.3 Configure your proxy 3.4 Rate limiter
  4. 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);

License

This project is licensed under the MIT license

Package Sidebar

Install

npm i tiny-cors-proxy

Weekly Downloads

29

Version

1.0.6

License

ISC

Unpacked Size

83 kB

Total Files

9

Last publish

Collaborators

  • vicfou-dev