簡體   English   中英

長沙發數據庫響應,使用aurelia fetch客戶端將400狀態發布到_user db

[英]couchdb response with 400 status posting to _user db using aurelia fetch client

這有點奇怪。 我打了一個長沙發,調用了ouchdb 2.0來更新用戶數據庫,然后返回401狀態消息“錯誤= bad_request”和“原因=引用標頭必須與主機匹配”。

但是,如果我將“ post”更改為“ put”,則它很高興,並按預期返回狀態201。 我可以繼續使用看跌期權,但這不是標准。

有什么建議嗎?

POST http://localhost:5984/_users/org.couchdb.user:test1 HTTP/1.1
Host: localhost:5984
Connection: keep-alive
Content-Length: 364
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:9000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
content-type: application/json
Accept: */*
DNT: 1
Referer: http://localhost:9000/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
Cookie: io=YBMMIY0pejGjeHV9AACO; AuthSession=foo

{
  "_id":"org.couchdb.user:test1",
  "_rev":"1-8e2136e07f62238327f87d1ae54a29df",
  "type":"user","roles": "user"],
  "name":"test1",
  "email":"test1@foo.bar",
  "fullName":"Test1 esq",
  "phone":"555-555-5555",
  "id":"org.couchdb.user:test1",
  "password_scheme":"pbkdf2",
  "iterations":10,
  "derived_key":"0e076f6f85f1389fd90ff181d433e1438e8e30a4",
  "salt":"37f590de042f07956f6cc11b8a9eb012"
}

響應

HTTP/1.1 400 Bad Request
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:9000
Access-Control-Expose-Headers: content-type, cache-control, accept-ranges, etag, server, x-couch-request-id, x-couch-update-newrev, x-couchdb-body-time
Cache-Control: must-revalidate
Connection: close
Content-Length: 67
Content-Type: application/json
Date: Thu, 29 Dec 2016 23:15:25 GMT
Server: CouchDB/2.0.0 (Erlang OTP/17)
X-Couch-Request-ID: b45ec52b5c
X-CouchDB-Body-Time: 0

{"error":"bad_request","reason":"Referer header must match host."}

**This works**

PUT http://localhost:5984/_users/org.couchdb.user:test1 HTTP/1.1
Host: localhost:5984
Connection: keep-alive
Content-Length: 364
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:9000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
content-type: application/json
Accept: */*
DNT: 1
Referer: http://localhost:9000/
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: io=62j8pWngSUNyLwKjAACX; AuthSession=xyyz

{
  "_id":"org.couchdb.user:test1",
  "_rev":"1-8e2136e07f62238327f87d1ae54a29df",
  "type":"user",
  "roles":["user"],
  "name":"test1",
  "email":"test1@foo.bar",
  "fullName":"Test1 esq",
  "phone":"555-555-5555",
  "id":"org.couchdb.user:test1",
  "password_scheme":"pbkdf2",
  "iterations":10,
  "derived_key":"0e076f6f85f1389fd90ff181d433e1438e8e30a4",
  "salt":"37f590de042f07956f6cc11b8a9eb012"
}

因此,由於端口號不同,您無法匹配引薦來源網址和預期的主機。 根據此https://github.com/couchbase/couchdb/blob/2.5.1.1/src/couchdb/couch_httpd.erl#L344,您可以將X-Forwarded-Host標頭放置為您的值-localhost:9000

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM