{"action":"created","issue":{"url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2157","repository_url":"https://api.github.com/repos/sandstorm-io/sandstorm","labels_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2157/labels{/name}","comments_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2157/comments","events_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2157/events","html_url":"https://github.com/sandstorm-io/sandstorm/pull/2157","id":162597222,"number":2157,"title":"Route/proxy non-main-host requests before sockjs's handler swallows them","user":{"login":"zarvox","id":307325,"avatar_url":"https://avatars.githubusercontent.com/u/307325?v=3","gravatar_id":"","url":"https://api.github.com/users/zarvox","html_url":"https://github.com/zarvox","followers_url":"https://api.github.com/users/zarvox/followers","following_url":"https://api.github.com/users/zarvox/following{/other_user}","gists_url":"https://api.github.com/users/zarvox/gists{/gist_id}","starred_url":"https://api.github.com/users/zarvox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zarvox/subscriptions","organizations_url":"https://api.github.com/users/zarvox/orgs","repos_url":"https://api.github.com/users/zarvox/repos","events_url":"https://api.github.com/users/zarvox/events{/privacy}","received_events_url":"https://api.github.com/users/zarvox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-28T03:54:51Z","updated_at":"2016-06-28T21:33:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sandstorm-io/sandstorm/pulls/2157","html_url":"https://github.com/sandstorm-io/sandstorm/pull/2157","diff_url":"https://github.com/sandstorm-io/sandstorm/pull/2157.diff","patch_url":"https://github.com/sandstorm-io/sandstorm/pull/2157.patch"},"body":"This fixes the longstanding \"Meteor app refresh loop\" issue.\r\n\r\nMeteor's sockjs inserts itself as the first request listener on the Meteor HTTP\r\nhandler object.  Normally, this is fine, and keeps DDP requests from\r\naccidentally getting routed to the application handlers.  This is problematic\r\nfor programs that happen to implement a proxy, and which need to proxy requests\r\nthat use the same paths and overall protocol as Meteor does internally.\r\n\r\nAs a result of the sockjs middleware being first in the chain, XHRs to an\r\nMeteor app's sockjs endpoint would wind up getting answered by Sandstorm's\r\ninstance of sockjs and communicating over DDP to Sandstorm itself.  So any app\r\nthat fell back to long-polling would speak DDP to Sandstorm, rather than to the\r\nintended app's backend.\r\n\r\nMeteor hashes all the code that goes into an app to determine if a reload is\r\nneeded to have the latest code running on the client.  It publishes the current\r\nversion of the client code in a collection over DDP.  This lead the code\r\nrunning in the browser to believe that there had been a code change, since it\r\nwas now getting the hash for **Sandstorm's** shell code over DDP, which did not\r\nmatch the hash for the app's code.  So the app would refresh the page, hoping\r\nto load the new code.  Browsers would cache that websockets had failed for that\r\nhost, and so the app would load the code, learn about Sandstorm's code version\r\nover sockjs long-polling DDP, and attempt to refresh again.\r\n\r\nThe solution here is to do Sandstorm's proxying earlier in the request dispatch\r\nchain.  We splice our own handler in after ddp-server has installed its sockjs\r\nhandler, and now everything works as intended.\r\n\r\nFixes #1186."},"comment":{"url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/comments/229190762","html_url":"https://github.com/sandstorm-io/sandstorm/pull/2157#issuecomment-229190762","issue_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2157","id":229190762,"user":{"login":"zarvox","id":307325,"avatar_url":"https://avatars.githubusercontent.com/u/307325?v=3","gravatar_id":"","url":"https://api.github.com/users/zarvox","html_url":"https://github.com/zarvox","followers_url":"https://api.github.com/users/zarvox/followers","following_url":"https://api.github.com/users/zarvox/following{/other_user}","gists_url":"https://api.github.com/users/zarvox/gists{/gist_id}","starred_url":"https://api.github.com/users/zarvox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zarvox/subscriptions","organizations_url":"https://api.github.com/users/zarvox/orgs","repos_url":"https://api.github.com/users/zarvox/repos","events_url":"https://api.github.com/users/zarvox/events{/privacy}","received_events_url":"https://api.github.com/users/zarvox/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T21:33:20Z","updated_at":"2016-06-28T21:33:20Z","body":"Garply, retest this please"}}
{"actor":{"display_login":"zarvox"}}