0

データを Redmine API に POST するレスト クライアントを構築しようとしています。Redmine (サーバー側) API で何かを変更できるとは思いません。アクセスを許可します。Redmine bitnami スタックをローカルにインストールしました (Redmine -> localhost/redmine)。クライアント側のファイルは localhost:8080 にあります

    $(document).ready(function(){
        $("#submit").on('click', function(){
            // send ajax
            $.ajax({
                url: 'http://localhost/redmine/projects.json', 
                type : "post", 
                crossDomain: true,
                dataType : 'json',
                headers: { 'X-Redmine-API-Key': 'admin' }, 
                data : JSON.stringify({
                          "project": {
                            "name": "MANOJ",
                            "identifier": "MANOJ-perera",
                             "description": "This is a des"
    
  }
}), 
                success : function(result) {
                  
                    alert("Sucess");
                    console.log(result);
                },
                error: function(xhr, resp, text) {
                    console.log(xhr, resp, text);
                }
            })
        });
    });

次のエラーが発生します。

XMLHttpRequest cannot load http://localhost/redmine/projects/11n. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 404.

この問題を解決するにはどうすればよいですか。助けてください。

4

1 に答える 1