Skip to content

Getting Started

To use Corsfix, add https://proxy.corsfix.com/? before your URL when making fetch requests.

// Add Corsfix URL before the API
// https://proxy.corsfix.com/? + https://api.example.com/data
fetch("https://proxy.corsfix.com/?https://api.example.com/data");
// GET request
fetch("https://proxy.corsfix.com/?https://api.example.com/users")
.then((response) => response.json())
.then((data) => console.log(data));
// POST request
fetch("https://proxy.corsfix.com/?https://api.example.com/users", {
method: "POST",
body: JSON.stringify({ name: "John" }),
headers: {
"Content-Type": "application/json",
},
});

If you would rather not build the proxy URL yourself, the Corsfix SDK wraps fetch for you. It works the same way from a script tag or from npm.

<script src="https://unpkg.com/corsfix"></script>
<script>
corsfix
.fetch("https://api.example.com/data")
.then((response) => response.json())
.then((data) => console.log(data));
</script>
import corsfix from "corsfix";
const response = await corsfix.fetch("https://api.example.com/data");

Using the SDK also lets your live website take advantage of the free tier.

You should use the domain whitelist via the dashboard. If that’s not possible for your use case, you can fall back to using an API key.

fetch("https://proxy.corsfix.com/?https://api.example.com/data", {
headers: {
"x-corsfix-key": "cfx_12345678",
},
});

We discourage using API key on the client side, as it can be exposed in your source code and browser network requests.