{"action":"created","comment":{"url":"https://api.github.com/repos/serverless/serverless/pulls/comments/74191247","id":74191247,"diff_hunk":"@@ -5,13 +5,27 @@ const _ = require('lodash');\n \n module.exports = {\n   compileMethods() {\n+    const corsConfig = {};\n     let endpointCounter = 1;\n-\n     _.forEach(this.serverless.service.functions, (functionObject, functionName) => {\n       functionObject.events.forEach(event => {\n         if (event.http) {\n           let method;\n           let path;\n+          let corsEnabled = false;\n+\n+          const headers = [\n+            'Content-Type',\n+            'X-Amz-Date',\n+            'Authorization',\n+            'X-Api-Key',\n+            'X-Amz-Security-Token'];\n+\n+          let cors = {","path":"lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js","position":21,"original_position":21,"commit_id":"a5587c2499bc7588631d58335290a6b1ecd1455b","original_commit_id":"a5587c2499bc7588631d58335290a6b1ecd1455b","user":{"login":"pmuens","id":1606004,"avatar_url":"https://avatars.githubusercontent.com/u/1606004?v=3","gravatar_id":"","url":"https://api.github.com/users/pmuens","html_url":"https://github.com/pmuens","followers_url":"https://api.github.com/users/pmuens/followers","following_url":"https://api.github.com/users/pmuens/following{/other_user}","gists_url":"https://api.github.com/users/pmuens/gists{/gist_id}","starred_url":"https://api.github.com/users/pmuens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmuens/subscriptions","organizations_url":"https://api.github.com/users/pmuens/orgs","repos_url":"https://api.github.com/users/pmuens/repos","events_url":"https://api.github.com/users/pmuens/events{/privacy}","received_events_url":"https://api.github.com/users/pmuens/received_events","type":"User","site_admin":false},"body":"Would be great if you can move this as well into the `if (!!event.http.cors)` section.","created_at":"2016-08-10T06:24:28Z","updated_at":"2016-08-10T06:24:28Z","html_url":"https://github.com/serverless/serverless/pull/1703#discussion_r74191247","pull_request_url":"https://api.github.com/repos/serverless/serverless/pulls/1703","_links":{"self":{"href":"https://api.github.com/repos/serverless/serverless/pulls/comments/74191247"},"html":{"href":"https://github.com/serverless/serverless/pull/1703#discussion_r74191247"},"pull_request":{"href":"https://api.github.com/repos/serverless/serverless/pulls/1703"}}},"pull_request":{"url":"https://api.github.com/repos/serverless/serverless/pulls/1703","id":79283463,"html_url":"https://github.com/serverless/serverless/pull/1703","diff_url":"https://github.com/serverless/serverless/pull/1703.diff","patch_url":"https://github.com/serverless/serverless/pull/1703.patch","issue_url":"https://api.github.com/repos/serverless/serverless/issues/1703","number":1703,"state":"open","locked":false,"title":"Enable CORS configuration for APIGW","user":{"login":"patoncrispy","id":2559414,"avatar_url":"https://avatars.githubusercontent.com/u/2559414?v=3","gravatar_id":"","url":"https://api.github.com/users/patoncrispy","html_url":"https://github.com/patoncrispy","followers_url":"https://api.github.com/users/patoncrispy/followers","following_url":"https://api.github.com/users/patoncrispy/following{/other_user}","gists_url":"https://api.github.com/users/patoncrispy/gists{/gist_id}","starred_url":"https://api.github.com/users/patoncrispy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patoncrispy/subscriptions","organizations_url":"https://api.github.com/users/patoncrispy/orgs","repos_url":"https://api.github.com/users/patoncrispy/repos","events_url":"https://api.github.com/users/patoncrispy/events{/privacy}","received_events_url":"https://api.github.com/users/patoncrispy/received_events","type":"User","site_admin":false},"body":"PR for Issue https://github.com/serverless/serverless/issues/1596\r\n\r\n##### Status:\r\nIn Development\r\n\r\n##### Description:\r\nI've added the origin headers to the methods that require it and the tests pass for those. Still need to add the preflight (OPTIONS) method as required. I was thinking that I should probably set this at the Resource level, as the preflight request needs to be able to assign the allow-methods setting, so will need to have a global view of all the methods that have CORS configurations applied. Feedback VERY welcome at this point! :)\r\n\r\n##### Todos:\r\n\r\n- [x] Add preflight.\r\n- [x] Write tests for preflight.\r\n","created_at":"2016-07-28T23:06:23Z","updated_at":"2016-08-10T06:24:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61f727f72f02faf8900bd8c0d77fbcc9d7f227b3","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/serverless/serverless/milestones/12","html_url":"https://github.com/serverless/serverless/milestones/v1.0.0-beta.2","labels_url":"https://api.github.com/repos/serverless/serverless/milestones/12/labels","id":1915239,"number":12,"title":"v1.0.0-beta.2","description":"The main goals for Beta 2 are: improved staging/region support, Environment variable support ,(including encryption), Better documentation, Better onboarding for new users\r\n","creator":{"login":"pmuens","id":1606004,"avatar_url":"https://avatars.githubusercontent.com/u/1606004?v=3","gravatar_id":"","url":"https://api.github.com/users/pmuens","html_url":"https://github.com/pmuens","followers_url":"https://api.github.com/users/pmuens/followers","following_url":"https://api.github.com/users/pmuens/following{/other_user}","gists_url":"https://api.github.com/users/pmuens/gists{/gist_id}","starred_url":"https://api.github.com/users/pmuens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmuens/subscriptions","organizations_url":"https://api.github.com/users/pmuens/orgs","repos_url":"https://api.github.com/users/pmuens/repos","events_url":"https://api.github.com/users/pmuens/events{/privacy}","received_events_url":"https://api.github.com/users/pmuens/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":40,"state":"open","created_at":"2016-08-01T09:05:58Z","updated_at":"2016-08-10T04:38:48Z","due_on":"2016-08-15T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/serverless/serverless/pulls/1703/commits","review_comments_url":"https://api.github.com/repos/serverless/serverless/pulls/1703/comments","review_comment_url":"https://api.github.com/repos/serverless/serverless/pulls/comments{/number}","comments_url":"https://api.github.com/repos/serverless/serverless/issues/1703/comments","statuses_url":"https://api.github.com/repos/serverless/serverless/statuses/a5587c2499bc7588631d58335290a6b1ecd1455b","head":{"label":"patoncrispy:feature/enable-cors","ref":"feature/enable-cors","sha":"a5587c2499bc7588631d58335290a6b1ecd1455b","user":{"login":"patoncrispy","id":2559414,"avatar_url":"https://avatars.githubusercontent.com/u/2559414?v=3","gravatar_id":"","url":"https://api.github.com/users/patoncrispy","html_url":"https://github.com/patoncrispy","followers_url":"https://api.github.com/users/patoncrispy/followers","following_url":"https://api.github.com/users/patoncrispy/following{/other_user}","gists_url":"https://api.github.com/users/patoncrispy/gists{/gist_id}","starred_url":"https://api.github.com/users/patoncrispy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patoncrispy/subscriptions","organizations_url":"https://api.github.com/users/patoncrispy/orgs","repos_url":"https://api.github.com/users/patoncrispy/repos","events_url":"https://api.github.com/users/patoncrispy/events{/privacy}","received_events_url":"https://api.github.com/users/patoncrispy/received_events","type":"User","site_admin":false},"repo":{"id":63854292,"name":"serverless","full_name":"patoncrispy/serverless","owner":{"login":"patoncrispy","id":2559414,"avatar_url":"https://avatars.githubusercontent.com/u/2559414?v=3","gravatar_id":"","url":"https://api.github.com/users/patoncrispy","html_url":"https://github.com/patoncrispy","followers_url":"https://api.github.com/users/patoncrispy/followers","following_url":"https://api.github.com/users/patoncrispy/following{/other_user}","gists_url":"https://api.github.com/users/patoncrispy/gists{/gist_id}","starred_url":"https://api.github.com/users/patoncrispy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patoncrispy/subscriptions","organizations_url":"https://api.github.com/users/patoncrispy/orgs","repos_url":"https://api.github.com/users/patoncrispy/repos","events_url":"https://api.github.com/users/patoncrispy/events{/privacy}","received_events_url":"https://api.github.com/users/patoncrispy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/patoncrispy/serverless","description":"Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! – ","fork":true,"url":"https://api.github.com/repos/patoncrispy/serverless","forks_url":"https://api.github.com/repos/patoncrispy/serverless/forks","keys_url":"https://api.github.com/repos/patoncrispy/serverless/keys{/key_id}","collaborators_url":"https://api.github.com/repos/patoncrispy/serverless/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/patoncrispy/serverless/teams","hooks_url":"https://api.github.com/repos/patoncrispy/serverless/hooks","issue_events_url":"https://api.github.com/repos/patoncrispy/serverless/issues/events{/number}","events_url":"https://api.github.com/repos/patoncrispy/serverless/events","assignees_url":"https://api.github.com/repos/patoncrispy/serverless/assignees{/user}","branches_url":"https://api.github.com/repos/patoncrispy/serverless/branches{/branch}","tags_url":"https://api.github.com/repos/patoncrispy/serverless/tags","blobs_url":"https://api.github.com/repos/patoncrispy/serverless/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/patoncrispy/serverless/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/patoncrispy/serverless/git/refs{/sha}","trees_url":"https://api.github.com/repos/patoncrispy/serverless/git/trees{/sha}","statuses_url":"https://api.github.com/repos/patoncrispy/serverless/statuses/{sha}","languages_url":"https://api.github.com/repos/patoncrispy/serverless/languages","stargazers_url":"https://api.github.com/repos/patoncrispy/serverless/stargazers","contributors_url":"https://api.github.com/repos/patoncrispy/serverless/contributors","subscribers_url":"https://api.github.com/repos/patoncrispy/serverless/subscribers","subscription_url":"https://api.github.com/repos/patoncrispy/serverless/subscription","commits_url":"https://api.github.com/repos/patoncrispy/serverless/commits{/sha}","git_commits_url":"https://api.github.com/repos/patoncrispy/serverless/git/commits{/sha}","comments_url":"https://api.github.com/repos/patoncrispy/serverless/comments{/number}","issue_comment_url":"https://api.github.com/repos/patoncrispy/serverless/issues/comments{/number}","contents_url":"https://api.github.com/repos/patoncrispy/serverless/contents/{+path}","compare_url":"https://api.github.com/repos/patoncrispy/serverless/compare/{base}...{head}","merges_url":"https://api.github.com/repos/patoncrispy/serverless/merges","archive_url":"https://api.github.com/repos/patoncrispy/serverless/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/patoncrispy/serverless/downloads","issues_url":"https://api.github.com/repos/patoncrispy/serverless/issues{/number}","pulls_url":"https://api.github.com/repos/patoncrispy/serverless/pulls{/number}","milestones_url":"https://api.github.com/repos/patoncrispy/serverless/milestones{/number}","notifications_url":"https://api.github.com/repos/patoncrispy/serverless/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/patoncrispy/serverless/labels{/name}","releases_url":"https://api.github.com/repos/patoncrispy/serverless/releases{/id}","deployments_url":"https://api.github.com/repos/patoncrispy/serverless/deployments","created_at":"2016-07-21T09:06:46Z","updated_at":"2016-07-21T09:06:47Z","pushed_at":"2016-08-09T21:15:09Z","git_url":"git://github.com/patoncrispy/serverless.git","ssh_url":"git@github.com:patoncrispy/serverless.git","clone_url":"https://github.com/patoncrispy/serverless.git","svn_url":"https://github.com/patoncrispy/serverless","homepage":"http://www.serverless.com","size":70733,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"serverless:v1.0","ref":"v1.0","sha":"990d7c5a089c2047cdd342fca88f6c006c53c4c3","user":{"login":"serverless","id":13742415,"avatar_url":"https://avatars.githubusercontent.com/u/13742415?v=3","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"repo":{"id":34302698,"name":"serverless","full_name":"serverless/serverless","owner":{"login":"serverless","id":13742415,"avatar_url":"https://avatars.githubusercontent.com/u/13742415?v=3","gravatar_id":"","url":"https://api.github.com/users/serverless","html_url":"https://github.com/serverless","followers_url":"https://api.github.com/users/serverless/followers","following_url":"https://api.github.com/users/serverless/following{/other_user}","gists_url":"https://api.github.com/users/serverless/gists{/gist_id}","starred_url":"https://api.github.com/users/serverless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serverless/subscriptions","organizations_url":"https://api.github.com/users/serverless/orgs","repos_url":"https://api.github.com/users/serverless/repos","events_url":"https://api.github.com/users/serverless/events{/privacy}","received_events_url":"https://api.github.com/users/serverless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/serverless/serverless","description":"Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! – ","fork":false,"url":"https://api.github.com/repos/serverless/serverless","forks_url":"https://api.github.com/repos/serverless/serverless/forks","keys_url":"https://api.github.com/repos/serverless/serverless/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serverless/serverless/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serverless/serverless/teams","hooks_url":"https://api.github.com/repos/serverless/serverless/hooks","issue_events_url":"https://api.github.com/repos/serverless/serverless/issues/events{/number}","events_url":"https://api.github.com/repos/serverless/serverless/events","assignees_url":"https://api.github.com/repos/serverless/serverless/assignees{/user}","branches_url":"https://api.github.com/repos/serverless/serverless/branches{/branch}","tags_url":"https://api.github.com/repos/serverless/serverless/tags","blobs_url":"https://api.github.com/repos/serverless/serverless/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serverless/serverless/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serverless/serverless/git/refs{/sha}","trees_url":"https://api.github.com/repos/serverless/serverless/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serverless/serverless/statuses/{sha}","languages_url":"https://api.github.com/repos/serverless/serverless/languages","stargazers_url":"https://api.github.com/repos/serverless/serverless/stargazers","contributors_url":"https://api.github.com/repos/serverless/serverless/contributors","subscribers_url":"https://api.github.com/repos/serverless/serverless/subscribers","subscription_url":"https://api.github.com/repos/serverless/serverless/subscription","commits_url":"https://api.github.com/repos/serverless/serverless/commits{/sha}","git_commits_url":"https://api.github.com/repos/serverless/serverless/git/commits{/sha}","comments_url":"https://api.github.com/repos/serverless/serverless/comments{/number}","issue_comment_url":"https://api.github.com/repos/serverless/serverless/issues/comments{/number}","contents_url":"https://api.github.com/repos/serverless/serverless/contents/{+path}","compare_url":"https://api.github.com/repos/serverless/serverless/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serverless/serverless/merges","archive_url":"https://api.github.com/repos/serverless/serverless/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serverless/serverless/downloads","issues_url":"https://api.github.com/repos/serverless/serverless/issues{/number}","pulls_url":"https://api.github.com/repos/serverless/serverless/pulls{/number}","milestones_url":"https://api.github.com/repos/serverless/serverless/milestones{/number}","notifications_url":"https://api.github.com/repos/serverless/serverless/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serverless/serverless/labels{/name}","releases_url":"https://api.github.com/repos/serverless/serverless/releases{/id}","deployments_url":"https://api.github.com/repos/serverless/serverless/deployments","created_at":"2015-04-21T03:48:40Z","updated_at":"2016-08-10T06:06:29Z","pushed_at":"2016-08-10T04:38:50Z","git_url":"git://github.com/serverless/serverless.git","ssh_url":"git@github.com:serverless/serverless.git","clone_url":"https://github.com/serverless/serverless.git","svn_url":"https://github.com/serverless/serverless","homepage":"http://www.serverless.com","size":72911,"stargazers_count":9784,"watchers_count":9784,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":680,"mirror_url":null,"open_issues_count":111,"forks":680,"open_issues":111,"watchers":9784,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/serverless/serverless/pulls/1703"},"html":{"href":"https://github.com/serverless/serverless/pull/1703"},"issue":{"href":"https://api.github.com/repos/serverless/serverless/issues/1703"},"comments":{"href":"https://api.github.com/repos/serverless/serverless/issues/1703/comments"},"review_comments":{"href":"https://api.github.com/repos/serverless/serverless/pulls/1703/comments"},"review_comment":{"href":"https://api.github.com/repos/serverless/serverless/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/serverless/serverless/pulls/1703/commits"},"statuses":{"href":"https://api.github.com/repos/serverless/serverless/statuses/a5587c2499bc7588631d58335290a6b1ecd1455b"}}}}
{"actor":{"display_login":"pmuens"}}