How to bypass CORS and Scrap any Websites using Javascript (Serverless)

Charly Berthet
3 min readNov 9, 2019

Nowadays it became almost impossible to directly request another website from your website. Due to some security rules you might face this famous CORS errors:

Access to fetch at ‘<websiteB>' from origin ‘<websiteA>' has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

In all our examples we will try to request https://www.semrush.com/ from our website using this one line Javascript:

fetch('https://www.semrush.com/').then(d => d.text()).then(d => console.log(d))

We can see in this example that SEMrush does not allow CORS from random websites.

To bypass this problem we need a proxy server. The good news is that some people already worked on this problem and have released there server online so we do not need to create our own! Some are free to use, some are freemium. In this article I will showcase with 1 line of code how to use them 💪

Free Proxy Server

Free Proxy Servers are not recommended for production purpose because we cannot guarantee their stability. Therefore your customers might

--

--