Cors Anywhere, For Everyone — Free / Reliable CORS proxy service

softmarshmallow
Grida
Published in
4 min readFeb 11, 2021

Free CORS Proxy server for everyone

While developing a service..

You’ll encounter CORS related error while developing your service. That could be cause of non https connection, or under development unstable server, or special usecase like developing a plugin like our case.

We’ve had the same problem. In our case, one of our product assistant, a Figma plugin, that runs on a iframe cannot access S3 bucket via axios / fetch (A js rest api library) since the origin is null on the iframe. We were previously using CORS anywhere for the solution. But it was slow, And un-reliable since it’s not backed by a corporation.

TL;DR — Jump to the cors demo → cors.sh/playground

Exactly Same as Cors Anywhere. Just Free and Faster.

The popular temporarial solution was using cors-anywhere. Sadly this is no longer an option. The https://cors-anywhere.herokuapp.com/ Is downgraded to demo usage only (with request limit, down buffed speed). And all the services relying on this was broken.

As a solution of this, we’ve opened up our cors proxy server (used by our product: assistant) and made available for everyone.

It’s now cors-anywhere-for-everyone.

Performance & Upgrades

  • up to 16mb payload per request
  • 10X ~ 20X Times faster than cors-anywhere
  • Blazing fast — Average of 50ms of latency
  • No X-RateLimit — Use as much, as frequent as you’re service desires.

Usage

The usage is quite straight forward. You only make request behind our url.

GET [<https://example.com/api/fetch-some-data>](<https://example.com/api/fetch-some-data>) to GET https://proxy.cors.sh/<https://example.com/api/fetch-some-data>

And all the headers, body, params can remain the same.

CURL Usage (simplest example)

curl \\
-H "Accept: application/json" \\
-H "Origin: grida.co" \\
-H "x-requested-with:XMLHttpRequest"
<https://proxy.cors.sh/https://google.com>
# where google.com shall be replaced with your desired target.

DEMO — Test your api on cors.sh/playground (powered by hoppscotch)

cors playground — cors.sh/playground

Using cors.sh/playground will automatically proxy your request to proxy.cors.sh and make it as CORS Error free request.

JS/TS SDK Usage

We’ve created a simple axios wrapper, which is totally up to you to use this, which is available on npm. (we’re using this for our projects)

  1. install bridged/client-sdk
  2. import ‘@bridged/client-sdk’
import { corsAxios } from '@bridged/client-sdk';... Async Functionconst { data } = await corsAxios.get("url");... Close Async Function

Or make your own implementation

function buildCorsFreeUrl(target: string): string{
return `https://proxy.cors.sh/${target}`
}
const corsFreeUrl = buildCorsFreeUrl("<https://google.com>");
fetch(corsFreeUrl)

Trouble shooting — Missing required request header?

Missing required request header. Must specify one of: origin,x-requested-with

The above error is thrown due to lack of http header origin or x-requested-with . this is required, and might change by the environment you are calling the request.

For instance on Insomnia, only origin header is required and the value can be empty. And on the browser environment since you cannot edit header easily you'll get to see the above message, which you can simply ignore and test your CORS Free api on cors.sh/playground.

For more details about this issue, please refer to #39 or open a new issue here

Development & Sources

This release is led by GwonHeeJun & Softmarshmallow.

  • Original cors-anywhere by Rob Wu
  • Playground forked from hoppscotch by hoppscotch team & community
  • serverless infra & deployment by Softmarshmallow

And since this service requires minimum wage to maintain, We’de love to have you as our sponsors.

Follow us

Please subscribe / follow to our medium, github, youtube, facebook, twitter and instagram for latest news on how we change developer’s life easier.

Special Thanks

special thanks to contributors all around the world making this world-shaking technologies! we are always welcoming designers, developers, researchers, copywriters, or any type of creators all around the world.

  • Hoppscotch & contributors
  • Cors anywhere by Rob — W & contributors

We are Grida. We make opensource design2code technologies.

grida.co

--

--