falcor
falcor copied to clipboard
cannot setup react-native with falcor
I have removed asap dependencies from falcor master branch, and it does work with cache. But when I include source: new FalcorHttpDatasource('http://localhost:9090')
data is not received. Not sure what is the problem. With falcor v0.1.15: source: new FalcorHttpDatasource('http://localhost:9090/model.json')
was enough to make it work
UPDATE Forgot to mention that I also use falcor-http-datasource master branch no the latest release version.
@almasakchabayev have you checked the CORS? I dunno, maybe it may be the case as React-Native runs on other posts than the backend (I believe).
@przeor I think the problem is with CORS. because in the browser (webpack-dev-server also runs on a different port) I had to do add the following to the datasource:
source: new FalcorHttpDatasource('http://localhost:9090/model.json', {
withCredentials: false,
crossDomain: true
}),
and in the server I have added app.use(cors({ origin: '*' }));
WIth this setup falcor works in browser with webpack-dev-server being on a different port. However similar setup does not seem to be working in React Native
@almasakchabayev have you got it right? If yes, please share solution for others ;-)
please also ping me on email [email protected] - @almasakchabayev, I have got some questions based on your GH profile about relay and falcor ;-)
@przeor No I have not. But really did not really try anything else.
I got it to work by changing this file: https://github.com/Netflix/falcor-http-datasource/blob/master/src/getCORSRequest.js.
'use strict'; // Get CORS support even for older IE module.exports = function getCORSRequest() { var xhr = new global.XMLHttpRequest(); if ('withCredentials' in xhr) { return xhr; } else if (!!global.XDomainRequest) { return new XDomainRequest(); } else { +++return xhr; --- throw new Error('CORS is not supported by your browser'); } };
@kcole16 Thanks for your sharing. It resolved our problem. 👍
@kcole16 Your solution saved me a day. Thank you!!