-
Notifications
You must be signed in to change notification settings - Fork 60
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
VITE_DEV_SERVER_URL returning random port #164
Comments
Workaround in if (process.env.VITE_DEV_SERVER_URL) {
mainWindow.loadURL("http://localhost:3000"); // dev
} else {
mainWindow.loadFile("dist/index.html"); // production
} |
This bug makes cookies and localstorage be lost at every electron restart. Since the port randomly changes the server origin changes, thus Electron (aka chromium) won't load the persisted data. |
Who can provide a 100% reproduction repo? |
Indeed this was the same issue for me. The current workaround for me is the following: if (process.env.VITE_DEV_SERVER_URL) {
mainWindow.loadURL("http://localhost:3000"); // dev
} else {
mainWindow.loadFile("dist/index.html"); // production
} |
@caoxiemeihao You can try the quick start demo and print VITE_DEV_SERVER_URL after running it. It will indeed be generated randomly every time and needs to be specified manually like above. My current temporary solution is to get 0.0.0.0 from process.env.NUXT_DEV and replace it. into localhost and put it in loadURL。 |
Since I upgraded my dependencies to the latest (see table), electron no longer starts on port 3000.
Vite seems to start on
3000
, however when I dump theVITE_DEV_SERVER_URL
variable it sayshttp://localhost:51316
🤔Any ideas?
The text was updated successfully, but these errors were encountered: