You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Rene Veerman <se...@gmail.com> on 2018/07/25 11:29:09 UTC
pouchdb : connecting to localhost doesn't work.. :(
javascript, run from localhost to a localhost apache and couchdb :
var db = new PouchDB('http://localhost:5984/sa_tree');
db.query(function (doc, emit) {
emit (doc);
}, {}).then(function (result) {
debugger;
}).catch(function (err) {
// handle any errors
debugger;
});
i get an TypeError: Failed to fetch
in the browser's network debugger tab, i can see the request failing :
1. Request URL:
http://localhost:5984/sa_tree/
2. Request Method:
OPTIONS
3. Status Code:
405 Method Not Allowed
4. Remote Address:
127.0.0.1:5984
5. Referrer Policy:
no-referrer-when-downgrade
1. Response Headersview source
1. Allow:
DELETE,GET,HEAD,POST
2. Cache-Control:
must-revalidate
3. Content-Length:
76
4. Content-Type:
application/json
5. Date:
Wed, 25 Jul 2018 11:19:42 GMT
6. Server:
CouchDB/2.1.2 (Erlang OTP/19)
7. X-Couch-Request-ID:
bd1bcc5d2a
8. X-CouchDB-Body-Time:
0
2. Request Headersview source
1. Accept:
*/*
2. Accept-Encoding:
gzip, deflate, br
3. Accept-Language:
nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
4. Access-Control-Request-Headers:
content-type
5. Access-Control-Request-Method:
GET
6. Connection:
keep-alive
7. Host:
localhost:5984
8. Origin:
http://localhost
9. Referer:
http://localhost/
10. User-Agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/66.0.3359.181 Safari/537.36
any idea why it's doing this?
is this mailinglist a good place to ask about pouchdb, or do i need to go
elsewhere with this question? if so, do you know where?
Re: pouchdb : connecting to localhost doesn't work.. :(
Posted by Rene Veerman <se...@gmail.com>.
thanks. that fixed it :)
On Wed, Jul 25, 2018 at 7:05 PM Martin Broerse <ma...@gmail.com>
wrote:
> Hi,
>
> Did you enable CORS ?
>
>
> - npm install -g add-cors-to-couchdb
> - add-cors-to-couchdb
>
> - Martin
>
> On Wed, Jul 25, 2018 at 5:18 PM Rene Veerman <se...@gmail.com>
> wrote:
>
> > javascript, run from localhost to a localhost apache and couchdb :
> >
> > var db = new PouchDB('http://localhost:5984/sa_tree');
> > db.query(function (doc, emit) {
> > emit (doc);
> > }, {}).then(function (result) {
> > debugger;
> > }).catch(function (err) {
> > // handle any errors
> > debugger;
> > });
> >
> > i get an TypeError: Failed to fetch
> >
> > in the browser's network debugger tab, i can see the request failing :
> >
> > 1. Request URL:
> > http://localhost:5984/sa_tree/
> > 2. Request Method:
> > OPTIONS
> > 3. Status Code:
> > 405 Method Not Allowed
> > 4. Remote Address:
> > 127.0.0.1:5984
> > 5. Referrer Policy:
> > no-referrer-when-downgrade
> > 1. Response Headersview source
> > 1. Allow:
> > DELETE,GET,HEAD,POST
> > 2. Cache-Control:
> > must-revalidate
> > 3. Content-Length:
> > 76
> > 4. Content-Type:
> > application/json
> > 5. Date:
> > Wed, 25 Jul 2018 11:19:42 GMT
> > 6. Server:
> > CouchDB/2.1.2 (Erlang OTP/19)
> > 7. X-Couch-Request-ID:
> > bd1bcc5d2a
> > 8. X-CouchDB-Body-Time:
> > 0
> > 2. Request Headersview source
> > 1. Accept:
> > */*
> > 2. Accept-Encoding:
> > gzip, deflate, br
> > 3. Accept-Language:
> > nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
> > 4. Access-Control-Request-Headers:
> > content-type
> > 5. Access-Control-Request-Method:
> > GET
> > 6. Connection:
> > keep-alive
> > 7. Host:
> > localhost:5984
> > 8. Origin:
> > http://localhost
> > 9. Referer:
> > http://localhost/
> > 10. User-Agent:
> > Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
> > Gecko) Chrome/66.0.3359.181 Safari/537.36
> >
> >
> > any idea why it's doing this?
> > is this mailinglist a good place to ask about pouchdb, or do i need to go
> > elsewhere with this question? if so, do you know where?
> >
>
Re: pouchdb : connecting to localhost doesn't work.. :(
Posted by Martin Broerse <ma...@gmail.com>.
Hi,
Did you enable CORS ?
- npm install -g add-cors-to-couchdb
- add-cors-to-couchdb
- Martin
On Wed, Jul 25, 2018 at 5:18 PM Rene Veerman <se...@gmail.com>
wrote:
> javascript, run from localhost to a localhost apache and couchdb :
>
> var db = new PouchDB('http://localhost:5984/sa_tree');
> db.query(function (doc, emit) {
> emit (doc);
> }, {}).then(function (result) {
> debugger;
> }).catch(function (err) {
> // handle any errors
> debugger;
> });
>
> i get an TypeError: Failed to fetch
>
> in the browser's network debugger tab, i can see the request failing :
>
> 1. Request URL:
> http://localhost:5984/sa_tree/
> 2. Request Method:
> OPTIONS
> 3. Status Code:
> 405 Method Not Allowed
> 4. Remote Address:
> 127.0.0.1:5984
> 5. Referrer Policy:
> no-referrer-when-downgrade
> 1. Response Headersview source
> 1. Allow:
> DELETE,GET,HEAD,POST
> 2. Cache-Control:
> must-revalidate
> 3. Content-Length:
> 76
> 4. Content-Type:
> application/json
> 5. Date:
> Wed, 25 Jul 2018 11:19:42 GMT
> 6. Server:
> CouchDB/2.1.2 (Erlang OTP/19)
> 7. X-Couch-Request-ID:
> bd1bcc5d2a
> 8. X-CouchDB-Body-Time:
> 0
> 2. Request Headersview source
> 1. Accept:
> */*
> 2. Accept-Encoding:
> gzip, deflate, br
> 3. Accept-Language:
> nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
> 4. Access-Control-Request-Headers:
> content-type
> 5. Access-Control-Request-Method:
> GET
> 6. Connection:
> keep-alive
> 7. Host:
> localhost:5984
> 8. Origin:
> http://localhost
> 9. Referer:
> http://localhost/
> 10. User-Agent:
> Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
> Gecko) Chrome/66.0.3359.181 Safari/537.36
>
>
> any idea why it's doing this?
> is this mailinglist a good place to ask about pouchdb, or do i need to go
> elsewhere with this question? if so, do you know where?
>