{"action":"created","issue":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/12741","repository_url":"https://api.github.com/repos/ampproject/amphtml","labels_url":"https://api.github.com/repos/ampproject/amphtml/issues/12741/labels{/name}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/12741/comments","events_url":"https://api.github.com/repos/ampproject/amphtml/issues/12741/events","html_url":"https://github.com/ampproject/amphtml/issues/12741","id":287221154,"node_id":"MDU6SXNzdWUyODcyMjExNTQ=","number":12741,"title":"Consuming locally served files from a nonlocal server results in an empty port some dynamically generated urls","user":{"login":"Adventive","id":34548005,"node_id":"MDQ6VXNlcjM0NTQ4MDA1","avatar_url":"https://avatars3.githubusercontent.com/u/34548005?v=4","gravatar_id":"","url":"https://api.github.com/users/Adventive","html_url":"https://github.com/Adventive","followers_url":"https://api.github.com/users/Adventive/followers","following_url":"https://api.github.com/users/Adventive/following{/other_user}","gists_url":"https://api.github.com/users/Adventive/gists{/gist_id}","starred_url":"https://api.github.com/users/Adventive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adventive/subscriptions","organizations_url":"https://api.github.com/users/Adventive/orgs","repos_url":"https://api.github.com/users/Adventive/repos","events_url":"https://api.github.com/users/Adventive/events{/privacy}","received_events_url":"https://api.github.com/users/Adventive/received_events","type":"User","site_admin":false},"labels":[{"id":284925157,"node_id":"MDU6TGFiZWwyODQ5MjUxNTc=","url":"https://api.github.com/repos/ampproject/amphtml/labels/Category:%20Tooling","name":"Category: Tooling","color":"1d76db","default":false},{"id":530202281,"node_id":"MDU6TGFiZWw1MzAyMDIyODE=","url":"https://api.github.com/repos/ampproject/amphtml/labels/P2:%20Soon","name":"P2: Soon","color":"e99695","default":false},{"id":255304066,"node_id":"MDU6TGFiZWwyNTUzMDQwNjY=","url":"https://api.github.com/repos/ampproject/amphtml/labels/Type:%20Bug","name":"Type: Bug","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"rsimha","id":26553114,"node_id":"MDQ6VXNlcjI2NTUzMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/26553114?v=4","gravatar_id":"","url":"https://api.github.com/users/rsimha","html_url":"https://github.com/rsimha","followers_url":"https://api.github.com/users/rsimha/followers","following_url":"https://api.github.com/users/rsimha/following{/other_user}","gists_url":"https://api.github.com/users/rsimha/gists{/gist_id}","starred_url":"https://api.github.com/users/rsimha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsimha/subscriptions","organizations_url":"https://api.github.com/users/rsimha/orgs","repos_url":"https://api.github.com/users/rsimha/repos","events_url":"https://api.github.com/users/rsimha/events{/privacy}","received_events_url":"https://api.github.com/users/rsimha/received_events","type":"User","site_admin":false},"assignees":[{"login":"rsimha","id":26553114,"node_id":"MDQ6VXNlcjI2NTUzMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/26553114?v=4","gravatar_id":"","url":"https://api.github.com/users/rsimha","html_url":"https://github.com/rsimha","followers_url":"https://api.github.com/users/rsimha/followers","following_url":"https://api.github.com/users/rsimha/following{/other_user}","gists_url":"https://api.github.com/users/rsimha/gists{/gist_id}","starred_url":"https://api.github.com/users/rsimha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsimha/subscriptions","organizations_url":"https://api.github.com/users/rsimha/orgs","repos_url":"https://api.github.com/users/rsimha/repos","events_url":"https://api.github.com/users/rsimha/events{/privacy}","received_events_url":"https://api.github.com/users/rsimha/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/ampproject/amphtml/milestones/4","html_url":"https://github.com/ampproject/amphtml/milestone/4","labels_url":"https://api.github.com/repos/ampproject/amphtml/milestones/4/labels","id":1537240,"node_id":"MDk6TWlsZXN0b25lMTUzNzI0MA==","number":4,"title":"Backlog Bugs","description":"This milestone tracks all bugs opened for the projects that are not yet assigned to a sprint milestone. Bugs within this milestone will be fixed based on the priority of the issue. ","creator":{"login":"rudygalfi","id":3888212,"node_id":"MDQ6VXNlcjM4ODgyMTI=","avatar_url":"https://avatars3.githubusercontent.com/u/3888212?v=4","gravatar_id":"","url":"https://api.github.com/users/rudygalfi","html_url":"https://github.com/rudygalfi","followers_url":"https://api.github.com/users/rudygalfi/followers","following_url":"https://api.github.com/users/rudygalfi/following{/other_user}","gists_url":"https://api.github.com/users/rudygalfi/gists{/gist_id}","starred_url":"https://api.github.com/users/rudygalfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudygalfi/subscriptions","organizations_url":"https://api.github.com/users/rudygalfi/orgs","repos_url":"https://api.github.com/users/rudygalfi/repos","events_url":"https://api.github.com/users/rudygalfi/events{/privacy}","received_events_url":"https://api.github.com/users/rudygalfi/received_events","type":"User","site_admin":false},"open_issues":510,"closed_issues":861,"state":"open","created_at":"2016-01-22T23:51:53Z","updated_at":"2018-09-11T10:49:22Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2018-01-09T20:32:00Z","updated_at":"2018-09-11T11:13:24Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## What's the issue?\r\nThe entry point for locally served files is almost correctly determined (in `3p-frame.js`). It incorrectly presumes the file is being served from a specific port on the nonlocal server and  tries to the use the port found in the location object from either the current window or parent window.\r\n\r\nThe missing port causes chrome to interpret `localhost` as a TLD and blocks it (because google owns the TLD).  \r\n\r\n## How do we reproduce the issue?\r\n- gulp\r\n  - no --host config\r\n- run secondary server \r\n- consume locally hosted files on secondary server\r\n  - i.e `<script async src=\"http://ads.localhost:8000/dist/amp.js\"></script>`\r\n  - in my case, i also have amp-ad, amp-iframe, amp-lightbox\r\n\r\n## What browsers are affected?\r\n- Chrome (as blocked)\r\n- other browsers might display a 404 \r\n\r\n## Which AMP version is affected?\r\n- version: 1515522516081\r\n\r\n------\r\n#### Potential fix\r\n\r\nThe issue stems in `3p-frame.js - getAdsLocalhost()` from when `win.location.port` && `win.parent.location.port` both are empty.\r\n``` javascript\r\nfunction getAdsLocalhost(win) {\r\n  let adsUrl = urls.thirdParty; // local dev with a non-localhost server\r\n  if (adsUrl.indexOf('ampproject.net') > -1) {\r\n    adsUrl = 'http://ads.localhost'; // local dev with a localhost server\r\n  }\r\n  return adsUrl + ':' + (win.location.port || win.parent.location.port);\r\n}\r\n```\r\n\r\nAdding a default port to the return fixes the issue. I wasn't able to find a variable referencing a default or set port so I simply hardcoded the default port.\r\n\r\nFix:\r\n``` javascript\r\nreturn adsUrl + ':' + (win.location.port || win.parent.location.port || 8000);\r\n```\r\n  "},"comment":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/comments/420237294","html_url":"https://github.com/ampproject/amphtml/issues/12741#issuecomment-420237294","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/12741","id":420237294,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDIzNzI5NA==","user":{"login":"ampprojectbot","id":23269078,"node_id":"MDQ6VXNlcjIzMjY5MDc4","avatar_url":"https://avatars3.githubusercontent.com/u/23269078?v=4","gravatar_id":"","url":"https://api.github.com/users/ampprojectbot","html_url":"https://github.com/ampprojectbot","followers_url":"https://api.github.com/users/ampprojectbot/followers","following_url":"https://api.github.com/users/ampprojectbot/following{/other_user}","gists_url":"https://api.github.com/users/ampprojectbot/gists{/gist_id}","starred_url":"https://api.github.com/users/ampprojectbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampprojectbot/subscriptions","organizations_url":"https://api.github.com/users/ampprojectbot/orgs","repos_url":"https://api.github.com/users/ampprojectbot/repos","events_url":"https://api.github.com/users/ampprojectbot/events{/privacy}","received_events_url":"https://api.github.com/users/ampprojectbot/received_events","type":"User","site_admin":false},"created_at":"2018-09-11T11:13:24Z","updated_at":"2018-09-11T11:13:24Z","author_association":"COLLABORATOR","body":"This issue hasn't been  updated in awhile. @rsimha Do you have any updates?"}}
{"actor":{"display_login":"ampprojectbot"}}