Skip to content

[Bug?]: Prerender fails with TypeError: Invalid URL when generating static routes (srvx/H3 URL constructed from path-only /) #2150

@samuscodes

Description

@samuscodes

During vite build with @solidjs/start + @solidjs/vite-plugin-nitro-2 for a static-site-generator, static prerendering fails when generating routes with the following error:

TypeError: Invalid URL
    at new URL (node:internal/url:828:25)
    code: 'ERR_INVALID_URL',
    input: '/'

The issue occurs during Nitro prerender phase and prevents any routes from being successfully prerendered.


Environment
SolidStart (2.0.0-alpha.2)
Vite 7.3.1
Node.js (24.13.0) / Bun (1.3.6)
@solidjs/vite-plugin-nitro-2
Nitro (v2 via SolidStart integration)
srvx (transitive dependency)
h3 (transitive dependency)

Steps to reproduce

  • create a new SolidStart project
  • enable Nitro plugin & set server/routes to static:
import { defineConfig } from "vite";
import { solidStart } from "@solidjs/start/config";
import { nitroV2Plugin } from "@solidjs/vite-plugin-nitro-2";

export default defineConfig({
  plugins: [
    solidStart(),
    nitroV2Plugin({
      routeRules: {
        "/": {
          prerender: true
        }
      }
    })
  ]
});

Run:

vite build

Expected behavior
All prerendered routes should generate successfully (at least /).


Actual behavior
Prerender fails with:

TypeError: Invalid URL

Triggered during URL normalization in srvx/H3 stack while handling a mocked request with req.url === "/".
No routes are successfully prerendered.

Stack trace excerpt

TypeError: Invalid URL
    at new URL (node:internal/url:828:25)
    at get _url (...srvx/_chunks/_url.mjs:43:16)
    at H3._findRoute
    at H3.handler
    at generateRoute
    at prerender

Analysis
The failure appears to originate from srvx URL wrapper logic:

this.#url = new NativeURL(this.href);

At prerender time, this.href resolves to a path-only value.
Node’s URL constructor requires an absolute URL, so this throws.

This suggests that during Nitro prerender:

  • request objects are created with url = "/" (path-only)
  • srvx lazily constructs a URL assuming it is absolute
  • no base/origin is provided in prerender context

Likely root cause
Mismatch between:

  • Nitro prerender mock request system (path-only URLs)
  • srvx URL abstraction (expects absolute URLs)
  • Node URL API (requires base for relative URLs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions