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

@ -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