Skip to content

corsmirror/CORSmirror

Repository files navigation

CORSmirror

What is CORSmirror?

CORSmirror is a RESTful API that provides a proxy to websites with CORS enabled.

The web service is built with:

For more information, check out the site, Replit, or the repository.

Usage

The RESTful API is as follows:

https://corsmirror.onrender.com/v1/cors?url=<url>

So if you want to fetch http://example.com, you can:

fetch('https://corsmirror.onrender.com/v1/cors?url=http://example.com')
  .then((response) => response.text())
  .then((data) => console.log(data));

You can also pass additional query strings that sets or overrides the response header fields:

fetch(
  'https://corsmirror.onrender.com/v1/cors?url=http://example.com&content-type=text/plain'
)
  .then((response) => response.headers.get('content-type'))
  .then((data) => console.log(data));

There are certain fields like Content-Length that cannot be overridden.

Development

Installation

Clone the repository:

git clone https://github.com/CORSmirror/CORSmirror.git
cd CORSmirror

Install the dependencies:

npm install

Run

Start the development server:

npm run dev

Start the production server:

npm start

Testing

Run tests:

npm test

Run lint:

npm run lint

Contributions

This is an open source project so feel free to fork the repository. Contributions are welcome!

License

MIT