Enable all origins via CORS header for custom schemes
authorPaul Betts <paul@paulbetts.org>
Tue, 24 Nov 2015 07:29:49 +0000 (23:29 -0800)
committerPaul Betts <paul@paulbetts.org>
Mon, 30 Nov 2015 19:08:43 +0000 (11:08 -0800)
This PR disables CORS for custom schemes, which allows you to serve Font
resources from custom schemes after using registerCustomSchemeAsSecure

atom/browser/net/url_request_buffer_job.cc
atom/browser/net/url_request_buffer_job.h
atom/browser/net/url_request_string_job.cc

index affc3dd37d252b3dfc360b85ae6bf9af4296e4ce..c4936ba15696a3300e66fd0baee1ec36d74e758b 100644 (file)
@@ -50,6 +50,9 @@ void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
   status.append("\0\0", 2);
   net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
 
+  std::string cors("Access-Control-Allow-Origin: *");
+  headers->AddHeader(cors);
+
   if (!mime_type_.empty()) {
     std::string content_type_header(net::HttpRequestHeaders::kContentType);
     content_type_header.append(": ");
index ab8de7e8f030603c4816e2f1882c068b71e1f2c7..8de5d82e0df21e5db0fe2429ced02248f5b57a02 100644 (file)
@@ -12,6 +12,8 @@
 #include "net/http/http_status_code.h"
 #include "net/url_request/url_request_simple_job.h"
 
+const std::string kCorsHeader("Access-Control-Allow-Origin: *");
+
 namespace atom {
 
 class URLRequestBufferJob : public JsAsker<net::URLRequestSimpleJob> {
index 4a631b813eff72e3b50b2633804493188d87d5a0..5d7a7dd017c9f5df88c0e7ea3ac2781d92960f30 100644 (file)
@@ -32,6 +32,9 @@ void URLRequestStringJob::GetResponseInfo(net::HttpResponseInfo* info) {
   std::string status("HTTP/1.1 200 OK");
   net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
 
+  std::string cors("Access-Control-Allow-Origin: *");
+  headers->AddHeader(cors);
+
   if (!mime_type_.empty()) {
     std::string content_type_header(net::HttpRequestHeaders::kContentType);
     content_type_header.append(": ");