查看完整版本: 如何在 nginx 上執行AJAX 跨網域存取網頁字型 Fonts


benchen72 2015-12-16 10:31

如何在 nginx 上執行AJAX 跨網域存取網頁字型 Fonts

W3C 提案Cross-Origin Resource Sharing(CORS),這份文件裡面提到,可以透過文件Header 設定可存取網域限制,以及存取方法、時間等,限制的部份有幾個:<br><br>(1)必須為http, https<br>(2)傳送資料方式為GET, POST<br>(3)資料格式為application/xml<br><br>Header 的部份宣告Access-Control-Allow-Origin,並且限制可存取網域為http://adj.com.tw,如果希望所有網站都可以存取可以使用"*"<br><br>實作:<br><br>只要在 nginx 的設定檔上...加上底下這串..就可以跨網域存取網頁字型 Fonts<br>[quote]<br>location ~* .(ttf|woff|eot|otf)$ {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;add_header Access-Control-Allow-Origin *;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;expires 8d;<br>}<br>[/quote]<br><br>這樣就可以囉~
頁: [1]
查看完整版本: 如何在 nginx 上執行AJAX 跨網域存取網頁字型 Fonts