remix-run/react-router · error

Prerender: No resolved URL is available from the Vite…

Error message

Prerender: No resolved URL is available from the Vite preview server

What it means

After the preview server starts, the plugin reads `previewServer.resolvedUrls?.local[0]` to learn the base URL for prerender requests. If Vite reports no local resolved URL (empty array or undefined), there is no address to request and the plugin aborts. This is an exotic failure: the server started but did not report where it is listening.

Solutions

  1. Check `preview.host` / `server.host` in vite.config.ts and let Vite resolve a local URL (default host)
  2. Align your Vite version with the one `@react-router/dev` declares as its peer
  3. Remove plugins that wrap or replace the preview server lifecycle

Example fix

// before (vite.config.ts)
preview: { host: 'example.test' }, // no local URL resolved

// after
preview: {}, // default localhost resolution
Defensive patterns

Strategy: validation

Validate before calling

// After starting preview, verify a local URL is resolvable
const server = await vite.preview({ logLevel: 'silent' });
if (!server.resolvedUrls?.local?.[0]) {
  throw new Error('No local URL resolved — check preview.host config');
}

Type guard

const hasLocalUrl = (s: { resolvedUrls?: { local?: string[] } } | null): s is { resolvedUrls: { local: [string, ...string[]] } } =>
  !!s?.resolvedUrls?.local?.[0];

Try / catch

try {
  await prerender({});
} catch (e) {
  if (e instanceof Error && e.message.includes('No resolved URL')) {
    // remove custom preview.host/server.host overrides and retry
  }
}

Prevention

When it happens

Trigger: A Vite version or custom middleware stripping `resolvedUrls`; `preview.host`/`server.host` combos (e.g. only `remote` URLs resolved, empty `local`) so `local[0]` is undefined; a wrapped/patched preview server returned instead of a real `PreviewServer`.

Common situations: Pinning unusual Vite versions or forks; plugins that intercept preview server creation; exotic networking configs in containers where local URL resolution fails.

Related errors


AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18). Data as JSON: /api/errors/1c01e8505bed1a17. Report an issue: GitHub.

Appendix: source

Thrown at packages/react-router-dev/vite/plugins/prerender.ts:571

      configFile: viteConfig.configFile,
      logLevel: "silent",
      preview: {
        port: 0,
        open: false,
      },
    });
  } catch (error) {
    throw new Error("Prerender: Failed to start Vite preview server", {
      cause: error,
    });
  }
}

function getResolvedUrl(previewServer: Vite.PreviewServer): URL {
  const baseUrl = previewServer.resolvedUrls?.local[0];

  if (!baseUrl) {
    throw new Error(
      "Prerender: No resolved URL is available from the Vite preview server",
    );
  }

  return new URL(baseUrl);
}

View on GitHub (pinned to 6beaca3952)