Wednesday, 6 October 2021

Free CORS Proxy List To Use With JavaScript

Free CORS Proxy List To Use With JavaScript

Whenever if you have tried to use some API or tried to get some information from the GET reuest via JavaScript XMLHttp Request or fetch(), you must have encountered the error similar that of below.

CORS error in chrome dev tools console

You can use free CORS proxy servers to bypass same-origin policy related to performing standard AJAX requests to 3rd party services. Usually it is not recommended to use these proxies in production mode, simply because you might have no control over it. But you can set up your own proxy server and use it.

These free CORS proxy server list here is made to use their API for development mode.

You can use to prevent mixed content of images and JSON data proxying the resources to serve them under https.

1. Codetabs CORS Proxy

API URL => "https://api.codetabs.com/v1/proxy?quest=<url_to_http_resource>"

- Each request is limited to 5mb size download to avoid abuse.

- Only supports GET request.

- Limit : 5 request per second. Once reached subsequent requests will result in error 429 (too many requests) until your quota is cleared.

2. origin.maskoding.com

API URL => https://origin.maskoding.com/?url=<url_to_http_resource>

- Only supports GET request.

3. All Origins


API URL => https://api.allorigins.win/get?url=<url_to_http_resource>

Example With JavaScript Fetch =>

fetch(`https://api.allorigins.win/get?url=${encodeURIComponent('https://wikipedia.org')}`)

                    .then(response => {

                      if (response.ok) return response.json()

                      throw new Error('Network response was not ok.')

                    })

                    .then(data => console.log(data.contents));

Example

Now suppose I need to get a contents of a page on Wikipedia to show a user on my web page, I can call fetch() to that particular URL via JavaScript. But the request won't get completed because of CORS or Cross-origin Resource Sharing.

For which you need to fetch() the webpage data from your server and then show it to user.

Now fortunately, we have these free APIs so that we don't actually need to set up a server to make all request with them.

SO above were the list. If you know any more proxy sites, do enter the links in the comment section so that others would also get to know about them. 😊

Saturday, 26 December 2020

Thursday, 5 November 2020

Sunday, 22 March 2020

How to Use Blogger API in JavaScript

How to Use Blogger API in JavaScript
Almost after a year, I'm back!

Talking about the Blogger, it the place where many Bloggers start their Blogging journey but may got offended by the facilities that blogger provide. They say WordPress has got a lot of futures than this!!

But here comes Google API into play, it provides us to access & carry out the desirable functions with the data on our blog. Apart from simply fetching the data, it facilitates us with modifications and saving of the content(i.e. posts, pages and comments).

I this tutorial we will be looking to use this API in JavaScript or jQuery.