withastro/astro · error · Error

No fallback route found for route ${route.route}

Error message

No fallback route found for route ${route.route}

What it means

Internal guard in getFallbackRoute(): no fallback route was found for the given route. Astro looks up i18n fallback routes by matching the route against each route's fallbackRoutes list; if none matches, the lookup fails with a plain Error. This indicates an inconsistency in the generated route table rather than a user mistake.

Source

Thrown at packages/astro/src/core/routing/helpers.ts:47

 *
 * It throws an error if no fallback routes were found. This means there's an error
 * when we construct the list of routes
 * @param route
 * @param routeList
 */
export function getFallbackRoute(route: RouteData, routeList: RouteInfo[]): RouteData {
	const fallbackRoute = routeList.find((r) => {
		// The index doesn't have a fallback route
		if (route.route === '/' && r.routeData.route === '/') {
			return true;
		}
		return r.routeData.fallbackRoutes.find((f) => {
			return f.route === route.route;
		});
	});

	if (!fallbackRoute) {
		throw new Error(`No fallback route found for route ${route.route}`);
	}

	return fallbackRoute.routeData;
}

/**
 * Return a user-provided 404 route if one exists.
 */
export function getCustom404Route(manifestData: RoutesList): RouteData | undefined {
	return manifestData.routes.find((r) => isRoute404(r.route));
}

/**
 * Return a user-provided 500 route if one exists.
 */
export function getCustom500Route(manifestData: RoutesList): RouteData | undefined {
	return manifestData.routes.find((r) => isRoute500(r.route));
}

View on GitHub (pinned to d081033d5f)

Solutions

  1. Confirm the route is expected to have a fallback under your i18n.routing config.
  2. For the index route '/', the helper expects the fallback to be the index itself — ensure a '/' route exists.
  3. If not an i18n route, do not call getFallbackRoute(); file an issue if Astro itself invoked it incorrectly.
Defensive patterns

Strategy: try-catch

Validate before calling

function hasFallbackRoute(route: RouteData, routeList: RouteInfo[]): boolean {
  return routeList.some(r => r.routeData.fallbackRoutes.some(f => f.route === route.route));
}
// check before calling getFallbackRoute

Try / catch

try {
  const fb = getFallbackRoute(route, routeList);
} catch (e) {
  if (e instanceof Error && /No fallback route/.test(e.message)) {
    // handle missing fallback (e.g. 404)
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getFallbackRoute() for a route that has no corresponding fallback (e.g. the index '/'); i18n config produces fallbackRoutes that don't reference the queried route; internal caller invoking the helper on an unsupported route.

Common situations: i18n fallback configuration changes; calling the helper outside the intended i18n flow; an internal regression where fallbackRoutes wasn't populated.

Related errors


AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12). Data as JSON: /api/errors/632d8ec4e32805b7. Report an issue: GitHub.