Skip to Content
Building Progressive Web Apps
book

Building Progressive Web Apps

by Tal Ater
September 2017
Intermediate to advanced
285 pages
7h 11m
English
O'Reilly Media, Inc.
Content preview from Building Progressive Web Apps

Appendix C. CORS Versus NO-CORS

When a site makes a request to a resource from a different origin, that request is known as a cross-origin request (COR); for example, when the page at https://www.gothamimperial.com/ attempts to load a stylesheet from https://maxcdn.bootstrapcdn.com/, or Analytics code from https://www.google-analytics.com/.

For security reasons, browsers allow pages to embed resources from a different origin, but they do not allow a script to read the content of a resource from another origin. This is known as the same-origin policy. An embed, such as when the Gotham Imperial Hotel uses a <link> tag to load a stylesheet from a CDN, is allowed, but making an Ajax request to read a JSON file from a different domain will be blocked.

Developers have often bypassed some of these limitations by embedding resources instead of accessing them directly (e.g., by using JSONP), but these were partial solutions that only worked in some cases and re-exposed their users to the security issues that the browsers attempted to solve (mainly cross-site scripting attacks).

Clearly, a better solution was needed.

Cross-origin resource sharing (CORS) is a new (less than a decade old) W3C standard used to define these interactions between the server and browser. Both the browser making the request as well as the server responding to it can determine how requests are handled. For example, a script can configure a request so that it can come from a different origin. But for the request ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Progressive Web Apps (PWA) - The Complete Guide

Progressive Web Apps (PWA) - The Complete Guide

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781491961643Errata Page