搜尋

首頁  >  問答  >  主體

七牛雲端儲存 - 七牛+Nginx+圖示字體=No 'Access-Control-Allow-Origin' header錯誤?

Font from origin 'http://img.***.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://***.com' is therefore not allowed access. The response had HTTP status code 403. (index):1
GET http://img.***.com/wp-content/themes/someone-v2/fonts/fontawesome-webfont.woff 

已經載入了

    location ~* \.(eot|otf|ttf|woff|svg)$ {
        add_header Access-Control-Allow-Origin *;
    }

font-awesome.min.css:

@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot');src:url('../fonts/fontawesome-webfont.eot') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff') format('woff'),url('../fonts/fontawesome-webfont.ttf') format('truetype'),url('../fonts/fontawesome-webfont.svg') format('svg');font-weight:normal;font-style:normal}

瀏覽器可存取到圖示字體,頁面提示403

這個怎麼破?

给我你的怀抱给我你的怀抱2782 天前1360

全部回覆(2)我來回復

  • 大家讲道理

    大家讲道理2017-05-16 17:27:15

    這個是因為你在七牛的空間中設置了防盜鏈,但是防盜鏈中沒有設置訪問css文件的域名,導致從css文件中訪問到的圖片的referer是css的域名,不在防盜鏈的白名單中,所以被403 forbidden了。

    回覆
    0
  • ringa_lee

    ringa_lee2017-05-16 17:27:15

    目測也要提供Access-Control-Allow-Methods和Access-Control-Allow-Headers頭

    回覆
    0
  • 取消回覆