【问题标题】:It must be 'true' to allow credentials. Origin 'null' is therefore not allowed access必须为“true”才能允许凭据。因此,Origin 'null' 不允许访问
【发布时间】:2016-01-20 00:32:36
【问题描述】:

我正在尝试这段代码:

$.ajax(
    {
         xhrFields: {
        withCredentials: true
    },

    url: 'http://localhost:5984/tdrepo/_design/tdr/_view/repopoolverified?group_level=1',
   type: "GET",

       success: function(result) {

        var $tr = $('<tr/>');
        $tr.append($('<td>').html(result.itemname));
         $tr.append($('<td>').html(result.Repository));
          $tr.append($('<td>').html(result.AIPcount));

            $('.list-order tr:last').before($tr);

但我收到此错误:

凭据标志为“true”,但“Access-Control-Allow-Credentials”标头为“”。必须为“真”才能允许凭据。因此,Origin 'null' 不允许访问。 我启用了 CORS: enable_cors = true
和 [cors] origins = * 但它仍然无法正常工作

【问题讨论】:

  • 服务器必须在 OPTIONS 预检请求上设置该标头,否则将无法发出完整请求

标签: jquery cors couchdb


【解决方案1】:

问题解决了! 我发现我需要使用 vim 进行这些更改: sudo vim /etc/couchdb/local.ini

enable_cors = true

[cors] 起源 = *

我没有找到 [cors] 所以我添加了它,但我把它放在了文件的最后; [管理员]之后

当我把它放在 (enable_cors = true ) 它奏效了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    • 2018-09-23
    • 1970-01-01
    相关资源
    最近更新 更多