Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 989 Bytes

middleware-cant-be-loaded.mdx

File metadata and controls

31 lines (22 loc) · 989 Bytes
title Can't load the middleware.
i18nReady true
githubURL https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts

import DontEditWarning from '~/components/DontEditWarning.astro'

MiddlewareCantBeLoaded: An unknown error was thrown while loading your middleware.

What went wrong?

Thrown in development mode when middleware throws an error while attempting to loading it.

For example:

import {defineMiddleware} from "astro:middleware";
throw new Error("Error thrown while loading the middleware.")
export const onRequest = defineMiddleware(() => {
  return "string"
});