vercel/next.js · error · Error
Invalid URL
Error message
Invalid URL
What it means
Minimal input guard in prepareAppPage (app-render.tsx): before parsing, the incoming request is checked for a URL and req.url is falsy. App Router rendering needs a relative URL to parse into route params and search params; with none present this sentinel error fires — the fault is the malformed/incomplete request object handed to the renderer, not user code.
Source
Thrown at packages/next/src/server/app-render/app-render.tsx:3309
serverComponentsHmrCache: ServerComponentsHmrCache | undefined,
sharedContext: AppSharedContext
) => Promise<RenderResult<AppPageRenderResultMetadata>>
type AppPagePreparation = {
url: ReturnType<typeof parseRelativeUrl>
parsedRequestHeaders: ParsedRequestHeaders
interpolatedParams: Params
postponedState: PostponedState | null
}
function prepareAppPage(
req: BaseNextRequest,
pagePath: string,
fallbackRouteParams: OpaqueFallbackRouteParams | null,
renderOpts: RenderOpts
): AppPagePreparation {
if (!req.url) {
throw new Error('Invalid URL')
}
const url = parseRelativeUrl(req.url, undefined, false)
// We read these values from the request object as, in certain cases,
// base-server will strip them to opt into different rendering behavior.
const parsedRequestHeaders = parseRequestHeaders(req.headers, {
isRoutePPREnabled: renderOpts.experimental.isRoutePPREnabled === true,
previewModeId: renderOpts.previewProps?.previewModeId,
})
const interpolatedParams = interpolateParallelRouteParams(
renderOpts.ComponentMod.routeModule.userland.loaderTree,
renderOpts.params ?? {},
pagePath,
fallbackRouteParams
)
View on GitHub (pinned to 258b1c1bc0)
Solutions
- Check the URL being parsed in your page/middleware; ensure it is an absolute, well-formed URL string.
- Wrap `new URL(...)` input with a base URL (e.g. `new URL(path, 'http://localhost')`) when the input may be relative.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/next/src/server/app-render/app-render.tsx:3276 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/next.js@258b1c1bc0 (2026-08-19).
Data as JSON: /api/errors/cea191f4b96c895c.
Report an issue: GitHub.