hoodiehq / faq

Frequently asked questions about Hoodie
faq.hood.ie
11 stars 3 forks source link

React and Hoodie. Can't connect to hoodie on a different domain #128

Closed nye closed 8 years ago

nye commented 8 years ago

Hello!

I'm new to Hoodie and Couch and I'm trying to understand but can't make them to work with React.

First, I've created a new hoodie app with hoodie new my_app

CouchDB started: http://127.0.0.1:6003 Waiting for CouchDB [*-----] SUCCESS WWW: http://127.0.0.1:6001 Admin: http://127.0.0.1:6002

Then, I have a React app running on a different domain and trying to connect to hoodie:

import Hoodie from 'hoodie-client';
const hoodie = new Hoodie({url: 'http://127.0.0.1:6003/_api'}); // I'm not sure what url goes here.

And when I try to login

hoodie.account.signIn({username: loginData.email, password: loginData.password});

I got this on browser console

PUT http://127.0.0.1:6003/_api/hoodie/account/api/session 404 (Not Found)
request.js:25 Uncaught TypeError: Cannot read property '0' of undefined

So, is it possible to do this? What's the correct URL?

Thank you!

gr2m commented 8 years ago

I’m sorry, this is our fault. We are about to release a new Hoodie version, and you got mixed up between the old and the new. hoodie-client is part of the new architecture, but hoodie new my_app gives you the old server right now.

You can follow these instructions to setup the new server instead: https://github.com/hoodiehq/hoodie-app-something-tracker#setup

ANd then do new Hoodie({url: 'http://127.0.0.1:8080/'}); or whatever portnumber you’ve set

nye commented 8 years ago

OK! It makes sense now ;) Thank you very much!

gr2m commented 8 years ago

sure :)