electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.5k stars 520 forks source link

Refused to load the font #3165

Closed hxj662630 closed 1 year ago

hxj662630 commented 1 year ago

Pre-flight checklist

Electron Forge version

6.0.5

Electron version

23.0.0

Operating system

win11 64bit 21H2

Last known working Electron Forge version

No response

Expected behavior

load custom font in the css file

the way i define the font in css file : @font-face { font-family: "NewUI"; src: url("../assets/font/CoreSansCR-15Thin.woff"); }

Actual behavior

Refused to load the font 'file:///D:/855b1791696e33e9ef80.woff' because it violates the following Content Security Policy directive: "default-src 'self' 'unsafe-eval' 'unsafe-inline' static: http: https: ws:". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.

cant load woff file

Steps to reproduce

image This is my project structure of directory

Additional information

Refused to load the font 'file:///D:/855b1791696e33e9ef80.woff' because it violates the following Content Security Policy directive: "default-src 'self' 'unsafe-eval' 'unsafe-inline' static: http: https: ws:". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.

ahmedkhabar commented 6 months ago

Hi, in my case I create an app using electron-forge with vite template and react, but when I try to use locale font like you, Is not working for me, and to solve this issue I use fontsource package to add locale fonts. I hope that's help you.