diff --git a/package.json b/package.json index d249be3..d69bbc0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-isomorphic-starterkit", "description": "Isomorphic starterkit with server-side React rendering.", - "version": "2.3.2", + "version": "2.3.3", "license": "BSD-3", "repository": { "type": "git", diff --git a/src/server.js b/src/server.js index ee9a34e..2da0c4f 100644 --- a/src/server.js +++ b/src/server.js @@ -24,7 +24,7 @@ server.route({ }); /** - * Endpoint that proxies all requests to api.github.com + * Endpoint that proxies all GitHub API requests to https://api.github.com. */ server.route({ method: "*", @@ -32,7 +32,7 @@ server.route({ handler: { proxy: { passThrough: true, - mapUri: function (request, callback) { + mapUri (request, callback) { callback(null, url.format({ protocol: "https", host: "api.github.com", diff --git a/src/views/Main.js b/src/views/Main.js index 6472629..8390a4a 100644 --- a/src/views/Main.js +++ b/src/views/Main.js @@ -145,13 +145,22 @@ export default Transmit.createContainer(Main, { * Return a Promise of the previous stargazers + the newly fetched stargazers. */ allStargazers (queryParams) { + /** + * On the server, connect to GitHub directly. + */ let githubApi = "https://api.github.com"; + /** + * On the client, connect to GitHub via the Hapi proxy route. + */ if (__CLIENT__) { const {hostname, port} = window.location; githubApi = `http://${hostname}:${port}/api/github`; } + /** + * Load a few stargazers using the Fetch API. + */ return fetch( githubApi + "/repos/RickWong/react-isomorphic-starterkit/stargazers" + `?per_page=100&page=${queryParams.nextPage}`