{"action":"created","issue":{"url":"https://api.github.com/repos/hoodiehq/hoodie/issues/493","repository_url":"https://api.github.com/repos/hoodiehq/hoodie","labels_url":"https://api.github.com/repos/hoodiehq/hoodie/issues/493/labels{/name}","comments_url":"https://api.github.com/repos/hoodiehq/hoodie/issues/493/comments","events_url":"https://api.github.com/repos/hoodiehq/hoodie/issues/493/events","html_url":"https://github.com/hoodiehq/hoodie/issues/493","id":156501801,"number":493,"title":"Authorization Problems with remote Hoodie","user":{"login":"rogeriochaves","id":792201,"avatar_url":"https://avatars.githubusercontent.com/u/792201?v=3","gravatar_id":"","url":"https://api.github.com/users/rogeriochaves","html_url":"https://github.com/rogeriochaves","followers_url":"https://api.github.com/users/rogeriochaves/followers","following_url":"https://api.github.com/users/rogeriochaves/following{/other_user}","gists_url":"https://api.github.com/users/rogeriochaves/gists{/gist_id}","starred_url":"https://api.github.com/users/rogeriochaves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogeriochaves/subscriptions","organizations_url":"https://api.github.com/users/rogeriochaves/orgs","repos_url":"https://api.github.com/users/rogeriochaves/repos","events_url":"https://api.github.com/users/rogeriochaves/events{/privacy}","received_events_url":"https://api.github.com/users/rogeriochaves/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-24T13:04:02Z","updated_at":"2016-05-25T16:45:03Z","closed_at":null,"body":"Hello, I have hoodie running in a separate project, there, my package.json just have one thing:\r\n\r\n```json\r\n\"dependencies\": {\r\n  \"hoodie\": \"^22.0.4\"\r\n}\r\n```\r\n(i've also tried \"git://github.com/hoodiehq/hoodie#tent\", same issues)\r\nThen I start it like this (I need to control all the ports and url because later I deploy this to heroku)\r\n```\r\nnode_modules/hoodie/bin/start.js --admin-password 123 --port 4000 --db-url http://admin:123@127.0.0.1:5984 --bind-address localhost\r\n```\r\n\r\nI get \"🐶  Your Hoodie app has started on http://localhost:4000\", okay, no problems here. (I've also tried changing localhost to 0.0.0.0 or 127.0.0.1, no luck)\r\n\r\nFor using, I add the hoodie script on my other project like this:\r\n```\r\n<script type=\"text/javascript\" src=\"//localhost:4000/hoodie/client.js\"></script>\r\n```\r\n\r\nAnd create the hoodie singleton like this (hoodie.js):\r\n```javascript\r\nconst hoodie = new Hoodie({url: 'http://localhost:4000'});\r\nexport default hoodie;\r\n```\r\n\r\nWhich I import on the other files to do stuff.\r\n\r\nBut when I try to sign up for example, by using this:\r\n```javascript\r\nhoodie.account.signUp({username, password})\r\n    .then(...)\r\n    .catch(...);\r\n```\r\n\r\nThose requests are made (copying from chrome and skipping the OPTIONS ones):\r\n\r\n**1 - account**\r\n\r\n> curl 'http://localhost:4000/hoodie/account/api/session/account' -X PUT -H 'Origin: http://localhost:8000' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,zh;q=0.2,gl;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2597.0 Safari/537.36' -H 'content-type: application/vnd.api+json' -H 'accept: application/vnd.api+json' -H 'Referer: http://localhost:8000/' -H 'Connection: keep-alive' --data-binary '{\"data\":{\"type\":\"account\",\"attributes\":{\"username\":\"3\",\"password\":\"123\"},\"id\":\"hwn2p6q\"}}' --compressed\r\n\r\n_Response_\r\n\r\n> 201 Created\r\n> {\"data\":{\"type\":\"account\",\"attributes\":{\"username\":\"3\",\"password\":\"123\"},\"id\":\"hwn2p6q\"}}\r\n\r\n**2 - session**\r\n\r\n> curl 'http://localhost:4000/hoodie/account/api/session' -X PUT -H 'Origin: http://localhost:8000' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,zh;q=0.2,gl;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2597.0 Safari/537.36' -H 'content-type: application/vnd.api+json' -H 'accept: application/vnd.api+json' -H 'Referer: http://localhost:8000/' -H 'Connection: keep-alive' --data-binary '{\"data\":{\"type\":\"session\",\"attributes\":{\"username\":\"3\",\"password\":\"123\"}}}' --compressed\r\n\r\n_Response_\r\n\r\n> 201 created\r\n> {\"links\":{\"self\":\"http://0.0.0.0:4000/session\"},\"data\":{\"id\":\"Mzo1NzU2QzJEMjo3KCIbT3ywciSszguYH4TA5oKSaw\",\"type\":\"session\",\"relationships\":{\"account\":{\"links\":{\"related\":\"http://0.0.0.0:4000/session/account\"},\"data\":{\"id\":\"hwn2p6q\",\"type\":\"account\"}}}},\"included\":[{\"id\":\"hwn2p6q\",\"type\":\"account\",\"attributes\":{\"username\":\"3\",\"roles\":[]},\"relationships\":{\"profile\":{\"links\":{\"related\":\"http://0.0.0.0:4000/session/account/profile\"},\"data\":{\"id\":\"hwn2p6q-profile\",\"type\":\"profile\"}}}}],\"meta\":{\"id\":\"1464094162685:rchaves-MacBook-Air.local:59312:iolfupsk:10004\"}}\r\n\r\n**3 - user**\r\n\r\n> curl 'http://localhost:4000/hoodie/store/api/user%2Fhwn2p6q/' -X OPTIONS -H 'Access-Control-Request-Method: GET' -H 'Origin: http://localhost:8000' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,zh;q=0.2,gl;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2597.0 Safari/537.36' -H 'Accept: */*' -H 'Referer: http://localhost:8000/' -H 'Connection: keep-alive' -H 'Access-Control-Request-Headers: accept, authorization' --compressed\r\n\r\n_Response_\r\n\r\n> 401 Unauthorized\r\n\r\nThen it keeps repeating the last request, with JS throwing\r\n```\r\nXMLHttpRequest cannot load http://localhost:4000/hoodie/store/api/user%2Fxy3hyvb/. Response for preflight has invalid HTTP status code 401\r\n```\r\n\r\nThis also happens after sign in, and hoodie shows nothing on its logs, even running with the `--verbose` option.\r\n\r\nIs this a CORS issue? What should I do? This setup used to work on very old hoodie versions (pre pouchdb)"},"comment":{"url":"https://api.github.com/repos/hoodiehq/hoodie/issues/comments/221635425","html_url":"https://github.com/hoodiehq/hoodie/issues/493#issuecomment-221635425","issue_url":"https://api.github.com/repos/hoodiehq/hoodie/issues/493","id":221635425,"user":{"login":"rogeriochaves","id":792201,"avatar_url":"https://avatars.githubusercontent.com/u/792201?v=3","gravatar_id":"","url":"https://api.github.com/users/rogeriochaves","html_url":"https://github.com/rogeriochaves","followers_url":"https://api.github.com/users/rogeriochaves/followers","following_url":"https://api.github.com/users/rogeriochaves/following{/other_user}","gists_url":"https://api.github.com/users/rogeriochaves/gists{/gist_id}","starred_url":"https://api.github.com/users/rogeriochaves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogeriochaves/subscriptions","organizations_url":"https://api.github.com/users/rogeriochaves/orgs","repos_url":"https://api.github.com/users/rogeriochaves/repos","events_url":"https://api.github.com/users/rogeriochaves/events{/privacy}","received_events_url":"https://api.github.com/users/rogeriochaves/received_events","type":"User","site_admin":false},"created_at":"2016-05-25T16:45:03Z","updated_at":"2016-05-25T16:45:03Z","body":"yeah, you are correct, I'll try to understand why mine still have issues when reloading and come back here"}}
{"actor":{"display_login":"rogeriochaves"}}