build(serve): added cors support for the js.server task

Added and used the cors middleware:
- add the module as a dev depedency in the package.json file
- require the module in the jsserve.js file
- add the module in the middleware list

Closes #7273

Closes #7274
This commit is contained in:
Thierry Templier 2016-02-25 09:28:01 +01:00 committed by Misko Hevery
parent 95af14b97c
commit 276fec6e50
4 changed files with 11 additions and 0 deletions

View File

@ -1831,6 +1831,9 @@
"core-util-is": {
"version": "1.0.2"
},
"cors": {
"version": "2.7.1"
},
"crc": {
"version": "3.3.0"
},

5
npm-shrinkwrap.json generated
View File

@ -2871,6 +2871,11 @@
"from": "core-util-is@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
},
"cors": {
"version": "2.7.1",
"from": "cors@>=2.7.1 <3.0.0",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.7.1.tgz"
},
"crc": {
"version": "3.3.0",
"from": "crc@3.3.0",

View File

@ -41,6 +41,7 @@
"chokidar": "^1.1.0",
"clang-format": "^1.0.32",
"conventional-changelog": "^0.2.1",
"cors": "^2.7.1",
"firefox-profile": "^0.3.4",
"fs-extra": "^0.26.3",
"glob": "^4.0.6",

View File

@ -1,5 +1,6 @@
var onHeaders = require('on-headers');
var proxy = require('proxy-middleware');
var cors = require('cors');
var url = require('url');
module.exports = function(gulp, plugins, config) {
@ -14,6 +15,7 @@ module.exports = function(gulp, plugins, config) {
var middlewares =
config.proxies.map(function(entry) { return makeProxy(entry.route, entry.url); });
middlewares.push(connect.favicon());
middlewares.push(cors());
// pub serve can't give the right content-type header for jsonp requests
// so we must turn off Chromium strict MIME type checking
// see https://github.com/angular/angular/issues/3030#issuecomment-123453168