Referer header required
- Dominant language
- JavaScript
- Stars
- 689
- Forks
- 167
- Avg merge
- 1h
- Merged PRs (30d)
- 1
Description
## Code:
```ts
export abstract class CouchDbService {
private readonly connection = nano(Utils.CouchDbUrlAuth);
private readonly db: DocumentScope;
constructor(dbName: DB) {
this.db = this.connection.use(dbName);
}
...
let mangoQuery = {
selector: {
_id: {$exists: true}
},
fields: ["_id"],
limit: 50
};
this.db.find(mangoQuery);
```
## Expected Behavior
Successful response
## Current Behavior
```json
{
"message": "Referer header required.",
"stack": "Error: Referer header required. at Request._callback (*\node_modules\nano\lib\nano.js:154:15) at Request.self.callback (*\node_modules\request\request.js:185:22) at Request.emit (events.js:189:13) at Request.EventEmitter.emit (domain.js:441:20) at Request. (*\node_modules\request\request.js:1161:10) at Request.emit (events.js:189:13) at Request.EventEmitter.emit (domain.js:441:20) at IncomingMessage. (*\node_modules\request\request.js:1083:12) at Object.onceWrapper (events.js:277:13)",
"name": "Error",
"error": "bad_request",
"reason": "Referer header required.",
"scope": "couch",
"statusCode": 400,
"request": {
"method": "POST",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "http://XXXXXX:XXXXXX@***/***/_find",
"body": "{"selector":{"_id":{"$exists":true}},"fields":["_id"],"limit":50}",
"qsStringifyOptions": {
"arrayFormat": "repeat"
}
},
"headers": {
"uri": "http://XXXXXX:XXXXXX@***/***/_find",
"statusCode": 400,
"date": "Mon, 29 Apr 2019 17:06:54 GMT",
"content-type": "application/json",
"cache-control": "must-revalidate"
},
"errid": "non_200",
"description": "couch returned 400"
}
```
## Possible Solution
hz
## Context
Trying to make search in CouchDB with MongoBD syntax;
## Your Environment
* Version used: 8.0.1
* Browser Name and version: ?
* Node: v10.15.3
* Operating System and version (desktop or mobile): Windows 10
* Link to your project: Proprietary
Contributor guide
Research direction
Reproduce the CouchDB Mango query from CouchDbService using Nano 8.0.1 and Node v10.15.3, then inspect the request and error path shown at node_modules/nano/lib/nano.js:154. Compare the request headers with the successful-response expectation; the work is done when the shown db.find(mangoQuery) call succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100