Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load the resource: Error has something to do with Access Control Allow Origin #9

Open
davidfufu opened this issue Sep 22, 2017 · 0 comments

Comments

@davidfufu
Copy link

davidfufu commented Sep 22, 2017

I'm using react and I have the example code in my return function.

		console.log(FBPostData);
		var stream = new Stream({
		    consumer_key: 'RHs4GdqsGH7QvTioGk3G3Tsf4',
		    consumer_secret: 'zPoZrZD9YqCH51FF0R5oQU8EJOX0IMz1JbwxY64Z44dT2u4pqE',
		    access_token_key: '	140915034-ckBaxPhhILbVyIeiYvMpyuPF9dx3ZbqxL5nrPBNE',
		    access_token_secret: 'fbAAa6LxYLjCN4MCeOj5uEpQVvqeKXbrk36o3bq1IkEza'
		});

		//create stream
		stream.stream();

		//listen stream data
		stream.on('data', function(json) {
		  console.log(json);
		});
		stream.on('error', function(err) {
		  console.log(err);
		});

The error that it returns is:

OPTIONS https://userstream.twitter.com/1.1/user.json 400 (Bad Request)
ClientRequest._onFinish @ request.js:132
(anonymous) @ request.js:62
EventEmitter.emit @ events.js:78
finishMaybe @ _stream_writable.js:607
afterWrite @ _stream_writable.js:470
afterTick @ index.js:40
Item.run @ browser.js:153
drainQueue @ browser.js:123
setTimeout (async)
runTimeout @ browser.js:41
process.nextTick @ browser.js:143
nextTick @ index.js:39
onwrite @ _stream_writable.js:458
WritableState.onwrite @ _stream_writable.js:169
ClientRequest._write @ request.js:254
doWrite @ _stream_writable.js:406
writeOrBuffer @ _stream_writable.js:395
Writable.write @ _stream_writable.js:322
exports.OAuth._performSecureRequest @ oauth.js:401
exports.OAuth._putOrPost @ oauth.js:470
exports.OAuth.post @ oauth.js:479
Stream.stream @ user-stream.js:66
render @ PostVisual.js:79
(anonymous) @ ReactCompositeComponent.js:795
measureLifeCyclePerf @ ReactCompositeComponent.js:75
_renderValidatedComponentWithoutOwnerOrContext @ ReactCompositeComponent.js:794
_renderValidatedComponent @ ReactCompositeComponent.js:821
performInitialMount @ ReactCompositeComponent.js:361
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
performInitialMountWithErrorHandling @ ReactCompositeComponent.js:316
mountComponent @ ReactCompositeComponent.js:255
mountComponent @ ReactReconciler.js:45
mountChildren @ ReactMultiChild.js:236
_createInitialChildren @ ReactDOMComponent.js:703
mountComponent @ ReactDOMComponent.js:522
mountComponent @ ReactReconciler.js:45
performInitialMount @ ReactCompositeComponent.js:370
mountComponent @ ReactCompositeComponent.js:257
mountComponent @ ReactReconciler.js:45
mountComponentIntoNode @ ReactMount.js:104
perform @ Transaction.js:143
batchedMountComponentIntoNode @ ReactMount.js:126
perform @ Transaction.js:143
batchedUpdates @ ReactDefaultBatchingStrategy.js:62
batchedUpdates @ ReactUpdates.js:97
_renderNewRootComponent @ ReactMount.js:319
_renderSubtreeIntoContainer @ ReactMount.js:401
render @ ReactMount.js:422
(anonymous) @ index.js:24
__webpack_require__ @ bootstrap c3ae3757f0d1cf6cbdb1:661
fn @ bootstrap c3ae3757f0d1cf6cbdb1:87
(anonymous) @ app.js:54243
__webpack_require__ @ bootstrap c3ae3757f0d1cf6cbdb1:661
(anonymous) @ bootstrap c3ae3757f0d1cf6cbdb1:707
(anonymous) @ bootstrap c3ae3757f0d1cf6cbdb1:707

As well as:

Twitter:1 Failed to load https://userstream.twitter.com/1.1/user.json: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant