require-fetch-default-export
Require a default export from Astro 7 advanced-routing entrypoints.
astro-doctor/require-fetch-default-export
Why it matters
Astro 7 reserves src/fetch.ts, src/fetch.js, src/fetch.mjs, and src/fetch.mts for advanced routing. A utility module using one of these names without a default export is loaded as a routing entrypoint and can break development or production startup.
See the difference
Incorrect
Reserved file contains only a named utility export
// src/fetch.ts
export const fetchJson = async (url: string) => {
const response = await fetch(url)
return response.json()
}Correct
Export an advanced-routing handler
// src/fetch.ts
import type { Fetchable } from 'astro'
import { astro, FetchState } from 'astro/fetch'
export default {
async fetch(request) {
return astro(new FetchState(request))
},
} satisfies FetchableConfigure this check
Project audits are configured in doctor.config.ts:
export default {
rules: {
'astro-doctor/require-fetch-default-export': 'error',
},
}Use 'error', 'warn', or 'off'. The configuration guide covers presets and per-file overrides.
Keep exploring best practices
- prefer-class-listUse class:list directive for conditional or dynamic class names.
- no-process-envDisallow process.env in Astro files — use import.meta.env instead.
- prefer-content-collectionsPrefer Content Collections over Astro.glob() or import.meta.glob() for Markdown and MDX files.
- no-legacy-astro-7-experimental-flagsMigrate experimental configuration fields removed or stabilized in Astro 7.
- prefer-env-schemaDefine an Astro env schema for variables documented in .env.example.
- prefer-pnpmUse pnpm consistently and remove competing package-manager lockfiles.
- require-client-router-script-lifecycleInitialize scripts on astro:page-load when using ClientRouter.
- require-content-configAdd a content config when src/content contains entries.