Skip to content

Fix server startup on Windows - #342

Merged
lissy93 merged 1 commit into
lissy93:masterfrom
kaanisthatyou:fix/windows-server-paths
Sep 14, 2026
Merged

lissy93 merged 1 commit into
lissy93:masterfrom
kaanisthatyou:fix/windows-server-paths

Conversation

@kaanisthatyou

Copy link
Copy Markdown
Contributor

Running the self-hosted server with node server (yarn start) fails on Windows for two reasons:

  1. __filename is computed with new URL(import.meta.url).pathname, which gives /C:/Users/.../server.js on Windows. The server then reads C:\C:\Users\...\package.json and stops at startup:

    Uncaught exception: Error: ENOENT: no such file or directory, open 'C:\C:\Users\...\web-check\package.json'
    

    pathname is also percent-encoded, so a checkout path containing spaces breaks the same way on macOS and Linux. fileURLToPath(import.meta.url) handles both.

  2. With that fixed, every API handler fails to load, because it is imported with import(path.join(dirPath, dirent.name)). On Windows an absolute path is not a valid ESM specifier:

    Unhandled rejection: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    

    The routes are never registered, so /api/* returns 404. The path is now converted with pathToFileURL(...).href.

Tested on Windows 11 / Node 24.14.0 with node server.js:

  • Before: the server fails at startup (1). With only (1) fixed, the server starts but GET /api/dns?url=example.com returns 404 and the log shows the ERR_UNSUPPORTED_ESM_URL_SCHEME rejections (2).
  • After: "Web-Check is up and running" and GET /api/dns?url=example.com returns 200 with the handler's JSON response.

I did not test on macOS or Linux, but both functions are standard Node APIs and behave the same there for paths without special characters.

🤖 Generated with Claude Code

https://claude.ai/code/session_016Wuh9RTwTUHB7wxpNxrSiw

@netlify

netlify Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for web-check ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a5bcda3
🔍 Latest deploy log https://app.netlify.com/projects/web-check/deploys/6aa752b0cc9a83000863da8b
😎 Deploy Preview https://deploy-preview-342--web-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@lissy93 lissy93 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll push the update on the last occourance which still needs updating on line 214

Comment thread server.js
app.use(express.static('dist/client/'));
app.use(async (req, res, next) => {
const ssrHandlerPath = path.join(__dirname, 'dist', 'server', 'entry.mjs');
import(ssrHandlerPath)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs updating too, like
import(pathToFileURL(ssrHandlerPath).href)

@lissy93
lissy93 merged commit 170c2ee into lissy93:master Sep 14, 2026
11 checks passed
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

Successfully merging this pull request may close these issues.

2 participants