Getting Past CORS In a Chrome Extension

Get past those annoying CORS-blocked sites.

If you want to know the basics of Google Chrome Extensions…

Check out my write-up here:

Or the video tutorial here:

Let’s begin…

Image for post
Image for post

Our manifest file…

To get past CORS on certain domains, simply add those domains to you permission property.

You must be exact in your domain listing.
For example, if you add a permission for the domain “https://www.yahoo.com" and make a fetch call inside your Chrome Extension to that domain…

Image for post
Image for post

…you will be blocked depending on how that domain decides to treat your request.

Yahoo redirects me to the URL “https://ca.yahoo.com/?p=us", and because I didn’t include that domain in permissions, I get blocked.

So if I add “https://ca.yahoo.com/?p=us" to my manifest…

Image for post
Image for post

…then make the fetch call…

Image for post
Image for post

…I successfully complete a fetch request to the domain.

For more web development tutorials, check out my YouTube channel,
An Object Is A.

Chrome Extension Getting Past CORS (Cross-Origin Resource Sharing)

Written by

Learning to code…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store