2

When I open my html file in browser , fonts blocked by firefox , I don't have any problem on other browsers and this happen just on mozila firefox.

Error :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resourceat file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/WebY ekan.woff. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/font awesome-webfont.woff2?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/font awesome-webfont.woff?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/fontawesome-webfont.ttf?v=4.5.0. (Reason: CORS request not http).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at file:///C:/Users/SajjaD/Desktop/PdfCar%20New%20Theme/Theme/PdfCar%20V2/fonts/dinar.woff. (Reason: CORS request not http).
4

1 回答 1

2

The reason you are getting a CORS error is likely because you are loading your font's via a network path file:///C:/... rather than an actual HTTP request.

disallows reading the remote resourceat file:

This message essentially means we found that you had something to load but we are not allowed to access it because it is a local file resource on the network drive in which we do not have permission to request.

You can probably bypass this error by correctly referencing your resources, so rather than pointing to file:///C:// you would start from the root folder that contains the website and request them from there e.g. ../website/assets/fonts/font-file.ttf. But this is a wild guess on the basis that I have no idea what tech stack you are developing with.

You can read more about it here : https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp

于 2019-08-08T19:59:22.740 回答