sensiblearts opened a new issue #1019: couch_peruser database 'does not exist' -- but I can see userdb- in Fauxton URL: https://github.com/apache/couchdb/issues/1019 <!--- Provide a general summary of the issue in the Title above --> ## Expected Behavior I have an elixir phoenix app that creates a new user in postgres and then PUTs the user's UUID to couchdb, ```elixir couch_url = "http://admin:adminpwd@localhost:5984/_users/org.couchdb.user:#{user.id}" ``` This works fine, and I see the new database in Fauxton, as userdb-[hex transform of user.id]. Then, I have a vue.js SPA that uses **pouchdb** has a copy of: the userdb name, and a proxy auth token generated by the phoenix app: ```elixir pouch_token = Base.encode16( :crypto.hmac(:sha, @couch_secret, user_id) ) ``` The vue.js app, when mounted, initializes like this: ```javascript const user = window.twnsdUser; Vue.create_pouchdb_for(user); setTimeout(() => { Vue.start_couchsync_for(user); }, 3000); // I added timeout just to see if it would help ``` I am expecting that the vuejs app will start syncing with the userdb-... ## Current Behavior .. but instead, the browser console shows: GET http://127.0.0.1:5984/userdb-35346535363736612D366634362D343266342D623336622D316431663466366531623833/_changes?timeout=true&style=all_docs&since=0&limit=100 404 (Object Not Found) - which it says is OK: "The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists" - so then, it tries (I assume) to create a new checkpoint: PUT http://127.0.0.1:5984/userdb-35346535363736612D366634362D343266342D623336622D316431663466366531623833/_local/lGk9S_oRIi0ARQ6PAyMfBw%3D%3D 404 (Object Not Found) - and gets 404 :-( ## Possible Solution * I am running couchdb as a Windows 10 service, and I am running my apps (phoenix, webpack vuejs) under Windows Subsystem for Linux; could this be a factor? Doesn't seem like it -- phoenix app creates user and userdb just fine. * could someone provide an example of a CURL statement (and corresponding user.id, and couch.secret) to http GET a userdb and/or PUT a doc into it and GET that? It would be nice to have a *known* working example so that I can rule out my headers, encryption hashing, etc. ## Steps to Reproduce (for bugs) 1. install couchdb on windows with msi installer 2. setup a single node on 127.0.0.1:5984 3. edit couchdb config in Fauxton to have: * credentials: true * headers: accept, authorization, content-type, origin, referer, X-auth-couchDB-UserName, X-Auth-CouchDB-Roles, X-Auth-CouchDB-Token * methods: OPTIONS, GET, PUT, POST, HEAD, DELETE * origin: * * couch_peruser: true * default_security: admin_local * enable_cors: true 4. copy couch_httpd_auth.secret to my app so it can generate the proxy auth token 5. restart couchdb, launch the vuejs app, and instead of successful sync, see infinite attempt to read then write chekpoint. The pouchdb local (browser) get/put works fine. But the remote sync fails. Here's the sync config in pouchdb: ```javascript Vue.start_couchsync_for = (userId) => { const couchdbToken = window.pouchToken; // from secret & user.id const couchdbName = window.couchDb; // userdb-[user.id] const headers = { 'X-Auth-CouchDB-UserName': `${userId}`, 'X-Auth-CouchDB-Roles': ['dbadmin'], 'X-Auth-CouchDB-Token': couchdbToken, 'Content-Type': 'application/json; charset=utf-8', }; Twnsd.remoteDatabase = new PouchDB(`${COUCHDB_URL}/${couchdbName}`, { cache: false, . skipSetup: true, ajax: { withCredentials: true, headers, }, }); PouchDB.sync(Twnsd.localDb, Twnsd.remoteDatabase, { live: true, heartbeat: false, timeout: true, retry: true, }); }; ``` ## Context I'm trying to get started with an offline vuejs app. ## Your Environment * Version used: couchdb 2.1.1, pouchdb 6.3.4 * Browser Name and version: chrome 62.0.3202.94 * Operating System and version (desktop or mobile): Windows 10 (vuejs app), and WSL (couchdb, phoenix app)
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
