2017-10-25 4 views
4

「Content-Length」ヘッダーが送信されていないことが本番環境で問題になっています。ヘッダープロパティでハードコードしても受信していますサーバーから411 Length Requiredエラーを返します。Axios:リクエストヘッダーにContent-Lengthヘッダーがありません

我々が使用している:

  • Axios問題を引き起こしているAWSラムダ環境

コード内にデプロイ0.16.2

  • NodeJS 6.10
  • アプリケーションは次のとおりです。

    let cookieJar; 
    const postBody = "MyBody=MyBodyContentGoesHere"; 
    const url = "https://my-url.com"; 
    return axios 
         .post(url, 
          postBody, 
          { 
           headers: { 
            'Content-Type': 'application/x-www-form-urlencoded' 
           }, 
           timeout: 10000, 
           jar: cookieJar, 
           withCredentials: true 
          } 
         ); 
    

    .NETでアプリケーションを作成しましたが、ヘッダーが正しく送信されました(手動で渡されることはありません)。この.NETアプリケーションはテストのためだけに書かれたものであり、実際のアプリケーションではありません。

    アイデアはありますか? axios githubプロジェクトで問題を開きますが、私は皆さんからいくつかのアイデアを知りたいと思います。

    ありがとうございます。

  • 答えて

    0

    "データ"フィールドを設定オブジェクトに追加しようとしましたか?

    let cookieJar; 
    const postBody = "MyBody=MyBodyContentGoesHere"; 
    const url = "https://my-url.com"; 
    return axios 
        .post(url, 
         postBody, 
         { 
          data: postBody, 
          headers: { 
           'Content-Type': 'application/x-www-form-urlencoded' 
          }, 
          timeout: 10000, 
          jar: cookieJar, 
          withCredentials: true 
         } 
        ); 
    
    +0

    私は試しましたが、動作しませんでした。 – thiago

    関連する問題