{"action":"opened","issue":{"url":"https://api.github.com/repos/Swiip/generator-gulp-angular/issues/620","labels_url":"https://api.github.com/repos/Swiip/generator-gulp-angular/issues/620/labels{/name}","comments_url":"https://api.github.com/repos/Swiip/generator-gulp-angular/issues/620/comments","events_url":"https://api.github.com/repos/Swiip/generator-gulp-angular/issues/620/events","html_url":"https://github.com/Swiip/generator-gulp-angular/issues/620","id":89700511,"number":620,"title":"The proxy middleware config in gulp/server is wrong","user":{"login":"lordfriend","id":1235614,"avatar_url":"https://avatars.githubusercontent.com/u/1235614?v=3","gravatar_id":"","url":"https://api.github.com/users/lordfriend","html_url":"https://github.com/lordfriend","followers_url":"https://api.github.com/users/lordfriend/followers","following_url":"https://api.github.com/users/lordfriend/following{/other_user}","gists_url":"https://api.github.com/users/lordfriend/gists{/gist_id}","starred_url":"https://api.github.com/users/lordfriend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordfriend/subscriptions","organizations_url":"https://api.github.com/users/lordfriend/orgs","repos_url":"https://api.github.com/users/lordfriend/repos","events_url":"https://api.github.com/users/lordfriend/events{/privacy}","received_events_url":"https://api.github.com/users/lordfriend/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-20T01:45:30Z","updated_at":"2015-06-20T01:45:30Z","closed_at":null,"body":"When I using the gulp/proxy file to make proxy for some api calls. I modified the last part to following\r\n```javascript\r\nmodule.exports = function(){\r\n    return [proxyMiddleware];\r\n}\r\n```\r\nI know this is not the suggested format in the comment, but the suggested format `module.exports = [proxyMiddleware]` will break because the following block of the gulpfile.js\r\n```javascript\r\n\r\nwrench.readdirSyncRecursive('./gulp').filter(function(file) {\r\n  return (/\\.(js|coffee)$/i).test(file);\r\n}).map(function(file) {\r\n  require('./gulp/' + file)(options);\r\n});\r\n```\r\nThis code snippet require all files in 'gulp' folder as an function and pass the option in.\r\n\r\nSo the only way to make the proxy file work is keep the original format as I mentioned above.\r\n\r\nBut this will not work! So the problem is in the gulp/server file. In **gulp/server** file the middleware is directly used as the `server.middleware` property. this is ok when you use `module.exports= [proxyMiddleware]`. But as we see you can't using that format.\r\n\r\nSo we need to change the **gulp/server** file. Simply add a function call to middleware require statement.\r\n\r\n```javascript\r\nvar middleware = require('./proxy')();\r\n```\r\n\r\nThen the proxy middleware will work as expected"}}