These are chat archives for redfin/react-server

9th
Jun 2016
Douglas Wade
@doug-wade
Jun 09 2016 23:27
so, I’m working on the bike share example from this pr redfin/react-server#222
And I’m trying to add a json endpoint middleware/page
I can curl the endpoint as expected:
» curl http://localhost:3000/api/networks | pbcopy
{{"company":"Nextbike GmbH","href":"/v2/networks/nextbike-limassol","id":"nextbike-limassol","location":{"city":"Limassol","country":"CY","latitude":34.6823,"longitude":33.0464},"name":"Nextbike"},{"company":"Nextbike GmbH","href":"/v2/networks/nextbike-mannheim","id":"nextbike-mannheim","location":{"city":"Mannheim","country":"DE","latitude":49.4621,"longitude":8.49054},"name":"VRNnextbike”}...
client.js?59ff:69error: [react-server.core.ClientController] Error with element promise 1 Object {original: null, response: Object, status: 404}original: nullresponse: Objectaccepted: falsebadRequest: falsebody: ObjectclientError: trueerror: Objectforbidden: falseinfo: falsenoContent: falsenotAcceptable: falsenotFound: trueok: falseserverError: falsestatus: 404statusType: 4text: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">↵<html><head>↵<title>404 Not Found</title>↵</head><body>↵<h1>Not Found</h1>↵<p>The requested URL /api/networks was not found on this server.</p>↵</body></html>↵"type: "text/html"unauthorized: falseproto: Objectstatus: 404proto: Objectlog @ client.js?59ff:69logger.(anonymous function) @ client.js?59ff:83(anonymous function) @ ClientController.js?7e9c:674_rejected @ q.js?bb27:844(anonymous function) @ q.js?bb27:870when @ q.js?bb27:1122Promise.promise.promiseDispatch @ q.js?bb27:788(anonymous function) @ q.js?bb27:604runSingle @ q.js?bb27:137flush @ q.js?bb27:125onNextTick @ main.js?b088:64Item.run @ browser.js?82e4:67drainQueue @ browser.js?82e4:37
client.js?59ff:69slow: [react-server.core.ClientController] renderAboveTheFold.fromStart Object {ms: 841}
The requested URL /api/networks was not found on this server.
Douglas Wade
@doug-wade
Jun 09 2016 23:32
Is there something wrong with my request?
this.data = ReactServerAgent.get('/api/networks’);
Douglas Wade
@doug-wade
Jun 09 2016 23:33
Do I need to handle promise fulfillment myself?
ReactServerAgent.get('/api/networks’).then(data => this.data = data);
uh...
huh?
Bo Borgerson
@gigabo
Jun 09 2016 23:34
Yeah... maybe that should be set up automatically by react-server-cli?
Would need to get the port dynamically.
Douglas Wade
@doug-wade
Jun 09 2016 23:36
If I were to host this on an ec2 instance fronted by an nginx reverse proxy, would I need a middleware for that as well?
Bo Borgerson
@gigabo
Jun 09 2016 23:36
Might also need some support for routing requests to other hosts.
Douglas Wade
@doug-wade
Jun 09 2016 23:36
Or is some trickery to make localhost work?
Bo Borgerson
@gigabo
Jun 09 2016 23:36
^ Yep.
Douglas Wade
@doug-wade
Jun 09 2016 23:38
essentially, the problem is that ReactServerAgent is trying to request http://localhost/api/networks, but needs to request http://localhost:3000/api/networks, so we add a middleware that prepends the :3000 to every request?
Bo Borgerson
@gigabo
Jun 09 2016 23:38
:thumbsup: