[2.0.1] Internal links do a full page load on a custom scheme (Electron app://)

Open
#755 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@saudademjj is already working on this.

Since Dec 1, 2026.

  • #756 by @saudademjj — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
electron, typescript
Domain
frontend, web-dev

Research direction

Start in src/data/events.ts at anchorUrl and review the protocol and origin checks described in the issue. Reproduce with the linked custom-scheme example and compare its behavior with npm run preview. The issue reports a fix and an open linked pull request (#756); the expected result is client-side navigation without incrementing the page-load counter.

Written by the indexing model from the issue text.

Description

Describe the bug

In an Electron app that serves its build from a custom scheme (app://example/ via protocol.handle), every click on an internal link does a full page load instead of client-side navigation.

Looks like it comes from the check added in #581 (for #382) in anchorUrl, src/data/events.ts:

if (url.protocol !== "https:" && url.protocol !== "http:") return;
if (url.origin !== window.location.origin || !isUnderBase(url.pathname, basePath)) return;

On an app:// page every link has url.protocol === "app:", so the router never handles it and the browser just navigates. The origin check below would actually pass: with app registered as a standard scheme, new URL("/about", document.baseURI).origin and location.origin are both app://example.

Same check is on 1.x too (went out in v1.0.1).

Your Example Website or App

https://github.com/devunt/solid-router-custom-scheme-repro

Steps to Reproduce the Bug or Issue
  1. npm install && npm run build && npm start
  2. The window shows a counter of full page loads. It starts at 1.
  3. Click "About".
  4. The counter goes to 2, so the page was reloaded.

With npm run preview (same build over http) the counter stays at 1.

Expected behavior

Clicking "About" navigates on the client like it does over http, and the counter stays at 1.

Screenshots or Videos

No response

Platform
  • OS: Linux
  • Browser: Electron 45.5.0 (Chromium 156)
  • Version: @solidjs/router 2.0.1
Additional context

Allowing the page's own scheme fixes it for me and still skips blob:/mailto:/tel:/data: links, since those never match the page's scheme:

-      if (url.protocol !== "https:" && url.protocol !== "http:") return;
+      if (url.protocol !== "https:" && url.protocol !== "http:" && url.protocol !== window.location.protocol) return;

I'm running 2.0.1 with this patched in and the counter in the repro stays at 1.

Dominant language
TypeScript
Stars
1.3k
Forks
193
Avg merge
8h 48m
Merged PRs (30d)
21

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from solidjs/solid-router

All issues in solidjs/solid-router

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.