{"action":"closed","issue":{"url":"https://api.github.com/repos/fuse-box/fuse-box/issues/871","repository_url":"https://api.github.com/repos/fuse-box/fuse-box","labels_url":"https://api.github.com/repos/fuse-box/fuse-box/issues/871/labels{/name}","comments_url":"https://api.github.com/repos/fuse-box/fuse-box/issues/871/comments","events_url":"https://api.github.com/repos/fuse-box/fuse-box/issues/871/events","html_url":"https://github.com/fuse-box/fuse-box/issues/871","id":265907504,"number":871,"title":"Enable loading remote files on the server","user":{"login":"leon-andria","id":1230744,"avatar_url":"https://avatars3.githubusercontent.com/u/1230744?v=4","gravatar_id":"","url":"https://api.github.com/users/leon-andria","html_url":"https://github.com/leon-andria","followers_url":"https://api.github.com/users/leon-andria/followers","following_url":"https://api.github.com/users/leon-andria/following{/other_user}","gists_url":"https://api.github.com/users/leon-andria/gists{/gist_id}","starred_url":"https://api.github.com/users/leon-andria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leon-andria/subscriptions","organizations_url":"https://api.github.com/users/leon-andria/orgs","repos_url":"https://api.github.com/users/leon-andria/repos","events_url":"https://api.github.com/users/leon-andria/events{/privacy}","received_events_url":"https://api.github.com/users/leon-andria/received_events","type":"User","site_admin":false},"labels":[{"id":470655876,"url":"https://api.github.com/repos/fuse-box/fuse-box/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-16T20:35:45Z","updated_at":"2017-10-19T21:16:41Z","closed_at":"2017-10-19T21:16:41Z","author_association":"CONTRIBUTOR","body":"Below is the line that silently resolve nothing on the server:\r\nhttps://github.com/fuse-box/fuse-box/blob/master/modules/fuse-box-responsive-api/index.js#L116.\r\n\r\nI locally tested the below code by adding it to https://github.com/fuse-box/fuse-box/blob/master/modules/fuse-box-responsive-api/index.js#L116.\r\n```javascript\r\n/* @if server */                \r\n        return new Promise(function(resolve, reject) {        \r\n            var http = require(\"http\");\r\n            var uri = require(\"url\");        \r\n            const srvUrl = uri.parse(url);        \r\n            http.get({\r\n                protocol: srvUrl.protocol,\r\n                hostname: srvUrl.hostname,\r\n                port: srvUrl.port,\r\n                path: srvUrl.path\r\n            }, function(resp){\r\n                resp.on('data', function(chunk){                \r\n                    resolve(evaluateModule(url, chunk.toString(), \"javascript\"));\r\n                });\r\n            }).on(\"error\", function(e){            \r\n                reject(e.message);\r\n            });\r\n        });               \r\n        /* @end */\r\n```\r\nIn addition, we need to modify the line below https://github.com/fuse-box/fuse-box/blob/master/modules/fuse-box-responsive-api/index.js#L272 with:\r\n\r\n```javascript\r\n/* @if server */\r\n                    var t = loadRemoteScript(id, isCSS);                    \r\n                    return resolve(t);\r\n                    /* @end */\r\n\r\n                    /* @if browser */\r\n                    return loadRemoteScript(id, isCSS);\r\n                    /* @end */\r\n```\r\n\r\nAnd I was able to successfully load the remote file.\r\n\r\nHowever, I was not able to implement the auto-detection the file type. As you see above on the evaluate function, the 3rd parameter is hard-coded to javascript.\r\nNow we know how to fix it, could you please implement the correct solution as I could not move any further.\r\n\r\nMy biggest problem now is that my project is on hold because it has an isomorphic code that should work on the server and the client. And the problem above is blocking me.\r\n\r\nPlease fix this as it will block any projects that use isomorphic code. (And can't wait any more :-))\r\n\r\nThank you"}}
{"actor":{"display_login":"nchanged"}}