Closed geohuz closed 1 year ago
Running in preview mode I saw the following error:
Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
Then I tried to fix the font src policy issue and now there is no error shows in the develop console. But the app window still has the same 404 error.
How to load your html file?
I'm using the vitejs react scaffolder to develop then moved to vite-electron, create a project then copy the files from old project over render directory, I'm not sure if the index.html has any problem:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Tree Org</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; img-src 'self' data:; font-src 'self' data:; script-src 'self'; style-src 'self' 'unsafe-inline'"
/>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
slightly changes in the content security rules for loading fonts and images.
yeah I'm using yarn create @quick-start/electron
to create the project, then moved my original vitejs source code into src/renderer
, running nicely in development. here is the project structure:
the hmr part in main/index.js is unchanged:
// HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production.
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
}
...
what is the preview mode?
Sorry it is in the package.json:
"start": "electron-vite preview",
I suspect the issue is with react-router, still trying to figure out...
My issue is with the react-router, change the router to hashrouter fix the issue.
Thanks!
Describe the bug
The application window shows the following error:
The app runs without any problem in development mode, set
export CSC_IDENTITY_AUTO_DISCOVERY=false
to skip the code sign to build the dmg.Electron-Vite Version
"electron-vite": "^1.0.25",
Electron Version
"electron": "^25.3.1", "electron-builder": "^23.6.0",
Vite Version
"vite": "^4.4.2"
Validations