Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App failed to load renderer page when path contains hash sign (#) in Windows prod #925

Closed
Tanimodori opened this issue Apr 18, 2023 · 5 comments · Fixed by #926
Closed
Assignees
Labels
bug Something isn't working

Comments

@Tanimodori
Copy link
Contributor

Tanimodori commented Apr 18, 2023

Describe the bug
The production build of this app won't load the renderer page when its path contains hash sign in Windows.

To Reproduce
Steps to reproduce the behavior:

git clone /~https://github.com/cawa-93/vite-electron-builder.git
cd vite-electron-builder
npm i
npm run compile
cd dist
mv win-unpacked #
cd #
./vite-electron-builder.exe

Expected behavior
The app will run normally

Screenshots

ConEmu64_ZV29mSMHGQ

vite-electron-builder_sQcQZcIkfi

vite-electron-builder_K4BCsBAdAY

Additional context
This is a known issue that WHATWG URL API doesn't expect # shown in the path of URL and interpret it as anchor of the web page. Nodejs legacy URL provides better support for native URLs. The WHATWG URL API that Nodejs adopted is not fully compatible with the legacy URL APIs.

There are solutions using url.parse. But unfortunately it is marked as "deprecated" rather than "legacy" for unknown reason despite the nodejs team said "We've backed off the deprecation of the legacy API". I propose that we can use BrowserWindow.loadFile provided by electron since it is not marked as deprecated or legacy yet. Although I suppose it uses those Nodejs legacy URL API internally lol.

See also

@cawa-93
Copy link
Owner

cawa-93 commented Apr 18, 2023

npm run compile is not actually production build, because in real production build all app's files are packed into asar archive. That case should be tested as well. To do that, you can change compile command like so:

cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js

@Tanimodori
Copy link
Contributor Author

npm run compile is not actually production build, because in real production build all app's files are packed into asar archive. That case should be tested as well. To do that, you can change compile command like so:

cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js

I've tested the pr with this build command which works in my local env.

@cawa-93
Copy link
Owner

cawa-93 commented Apr 18, 2023

I mean, does issue with # reproduces in "real production" build?

@Tanimodori
Copy link
Contributor Author

It is reproducable with the actual prod build command on the original repo. Just modify the path to include a "#".

@Tanimodori
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants