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

ERR_CONNECTION_REFUSED when starting node server from sveltekit #40

Open
mbakker96 opened this issue Mar 19, 2024 · 0 comments
Open

ERR_CONNECTION_REFUSED when starting node server from sveltekit #40

mbakker96 opened this issue Mar 19, 2024 · 0 comments

Comments

@mbakker96
Copy link

Hi,

I'm have a Sveltekit application that I want to run inside electron. I choose the option to export my svelte kit application into node application. It works perfectly when running it with node build-folder. But when starting it inside electron the node server does not startup.

Removing tthe hostname and scheme will response in a ERR_FILE_UNKNOW error.

import { app, BrowserWindow } from 'electron';
import serve from 'electron-serve'

const loadURL = serve({
  directory: 'build',
  hostname: '0.0.0.0:3000',
  scheme: 'http'
});
let mainWindow;

(async () => {
	await app.whenReady();

	mainWindow = new BrowserWindow();

	await loadURL(mainWindow);

})();
npx electron-forge start -l   
✔ Checking your system
✔ Locating application
⠋ Loading configuration
✔ Locating application
✔ Loading configuration
✔ Preparing native dependencies [0.1s]
✔ Running generateAssets hook
⠋ [plugin-vite] Launching dev servers for renderer process code
◼ [plugin-vite] Compiling main process code
✔ [plugin-vite] Launching dev servers for renderer process code [0.0s]
⠋ [plugin-vite] Compiling main process code
vite v5.1.6 building for development...

watching for file changes...
vite v5.1.6 building for development...
✔ [plugin-vite] Launching dev servers for renderer process code [0.0s]
⠙ [plugin-vite] Compiling main process code

build started...

build started...
✓ 1 modules transformed.
Generated an empty chunk: "preload".
✓ 1 modules transformed.
.vite/build/main.js  0.62 kB │ gzip: 0.33 kB
built in 25ms.
✔ [plugin-vite] Launching dev servers for renderer process code [0.0s]
✔ [plugin-vite] Compiling main process code [0.0s]

(node:11662) electron: Failed to load URL: http://0.0.0.0:3000/ with error: ERR_CONNECTION_REFUSED
(Use `Electron --trace-warnings ...` to show where the warning was created)
(node:11662) UnhandledPromiseRejectionWarning: Error: ERR_CONNECTION_REFUSED (-102) loading 'http://0.0.0.0:3000/'
    at rejectAndCleanup (node:electron/js2c/browser_init:2:74086)
    at WebContents.failListener (node:electron/js2c/browser_init:2:74299)
    at WebContents.emit (node:events:514:28)
(node:11662) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[11662:0319/131328.898771:INFO:CONSOLE(2)] "%cElectron Security Warning (Insecure Content-Security-Policy) font-weight: bold; This renderer process has either no Content Security
  Policy set or a policy with "unsafe-eval" enabled. This exposes users of
  this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: node:electron/js2c/sandbox_bundle (2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant