Reputation: 3863
I have successfully set everything up but unfortunately my GraphQL endpoint is not at the same location as the website that serves the client side.
I know this because in the error console of the browser it says :
http://localhost:3000/graphql Failed to load resource: the server responded with a status of 404 (Not Found)
three times then give up.
The page that I am using Relay is indeed at http://localhost:3000/
but my GraphQL endpoint is at http://localhost:5000/graphql
. Looks like it uses the current URL then automatically append /graphql
to it. How can I instruct Relay to get data from other place?
Upvotes: 0
Views: 148
Reputation: 3863
Ok, I found it. (https://facebook.github.io/relay/docs/guides-network-layer.html)
Relay.injectNetworkLayer(
new Relay.DefaultNetworkLayer('http://example.com/graphql')
);
And just in case you are running this on localhost
it is still subjected to CORS because it is on different port. In my case I am using an Express server for GraphQL endpoint so I used cors
middleware to whitelist my other page.
Upvotes: 2