Cross Origin Resource Sharing (CORS) Blocked for Cloudfront

by | 5 Dec 2016 | Amazon Web Services (AWS), Cloudfront, S3, Server, Technology | 0 comments

Cross Origin Resource Sharing is a very common issue faced.

You will usually get the message like the following.

Font from origin ‘https://k3j3jd3k2j.cloudfront.net’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://mervcodes.wpengine.com’ is therefore not allowed access.

There are two ways to resolve this issue.

Solution 1: S3 Bucket Way

This is the most common solution, which is to set the CORS header in your S3 bucket.

http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html

 

Solution 2: DNS Way

Step 1

Create a subdomain like

cdn.mervcodes.com

instead of using

k3j3jd3k2j.cloudfront.net

Step 2

Create a CNAME record that points

cdn.mervcodes.com

to

k3j3jd3k2j.cloudfront.net

 

That’s it. You are done!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

Amazon Web Services (AWS)ApacheCentOSDatabaseLinuxMySQLOSProgrammingServerTechnology
8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

This tutorial will be guiding you in setting up a web server with pre-installed Centos. In summary, you will be installing Apache and MySQL, and learning how to configure virtual hosts in Apache. Note: before proceeding with this tutorial. Make sure you figure out...

AppleiOSMobile PhonesObjective-CProgrammingSwiftTechnology
How to install Cocoapods for Objective-C/Swift development on Mac OS?

How to install Cocoapods for Objective-C/Swift development on Mac OS?

Steps to install Cocoapods Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on...

AndroidAndroidAppleiOSJavaMobile PhonesObjective-CProgramming
iPhone Camera
Complete overview of the mobile app development process (Infographic)

Complete overview of the mobile app development process (Infographic)

Clients always have the misperception that developing a mobile app is as easy as developing a mobile application would be a walk in a park without much effort involved. The following infographic pretty much sums up the total cost and effort for mobile app...