Angular gzip json file automatically : Refused to set unsafe header “Accept-Encoding”

前端 未结 1 947
别那么骄傲
别那么骄傲 2021-01-11 12:58

I use a gzip json static file on my server (actually, it\'s my test server) and the data i receive is always compressed.

Here is my code :

    $http(         


        
相关标签:
1条回答
  • 2021-01-11 13:54

    You shouldn't set the request header "Accept-Encoding". This is set automatically by the browser. See this Q&A for a list a browsers that accept gzip.

    On the server side, you will need to set the Content-Encoding to:

    Content-Encoding: gzip
    

    Then the response should be automatically decompressed by the browser.

    0 讨论(0)
提交回复
热议问题