Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referer header required #156

Open
akopchinskiy opened this issue Apr 29, 2019 · 2 comments
Open

Referer header required #156

akopchinskiy opened this issue Apr 29, 2019 · 2 comments

Comments

@akopchinskiy
Copy link

akopchinskiy commented Apr 29, 2019

Code:

export abstract class CouchDbService {
    private readonly connection = nano(Utils.CouchDbUrlAuth);
    private readonly db: DocumentScope<string>;

    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

{
"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.<anonymous> (*\node_modules\request\request.js:1161:10) at Request.emit (events.js:189:13) at Request.EventEmitter.emit (domain.js:441:20) at IncomingMessage.<anonymous> (*\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:https://XXXXXX:XXXXXX@***/***/_find",
"body": "{"selector":{"_id":{"$exists":true}},"fields":["_id"],"limit":50}",
"qsStringifyOptions": {
"arrayFormat": "repeat"
}
},
"headers": {
"uri": "http:https://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
@ijsnow
Copy link

ijsnow commented Jun 8, 2019

I'm getting the same via the homebrew installation with the following code:

export async function getUserByEmail(email: string): Promise<IUser> {
  const users = nano.use('users')
  const resp = await users.find({
    fields: ["emails"],
    selector: {
      emails: {
        $elemMatch: {
          $eq: email,
        },
      },
    },
  });

  // ...
}

@ludjosorio
Copy link

any solution? i'm getting the same error.
async function find() {
try {
const dbMobile = mobileNano.db.use("myDb");
const data = await dbMobile.find({
params: {
selector: {
"|type": "user",
},
},
});
console.log("dd", data);
} catch (error) {
console.log("Error: ", error);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants