react-pouchdb
react-pouchdb copied to clipboard
Error when using `useFind` and `pouchdb-server`
I'm using your library in a React project of mine and it's been working excellently for local databases. Thanks for putting this together!
Now I'm working on synchronizing the database with a pouchdb-server instance. The connection seems to work fine, but calls to useFind are now giving me 400 Bad Request errors when the library tries to access the /_find endpoint on the remote database.
Is there something special I need to do to make useFind work with pouchdb-server?
Hi! Nice to hear. Thanks for the support!
There shouldn't be anything special to get started using a remote database. Todoapp seems to work with pouchdb-server and http://localhost:5984/todoapp as the database name.
In a real app it's usually necessary to modify the fetch options. I use pouchdb-server for development. Setup like this works well for me:
<PouchDB
name="http://example.com/dbname"
fetch={(url, opts) => {
opts.headers.set('authorization', `Bearer ${token}`); // For external JWT auth
return fetch(url, {
...opts,
credentials: 'omit'
});
}}
>
...
</PouchDB>
Hope this helps, but if not, please post the request and response headers and let's have a look.
Thanks for your reply. This is for a project I'm working on in my spare time so I likely won't have a chance to try your suggestion before the weekend. I'll let you know how it goes.
I ended up abandoning this project so I'll close this as likely being something I did wrong on my end.