Skip to content

HAMUR_E1246: A route middleware file name says global, a side or an order

A route middleware file name says global, a side or an order. Error HAMUR_E1246 belongs to hamur, scan, build and dev (1001 – 1999).

Message

text
HAMUR_E1246 <file>: a file name no longer makes a route middleware global; import it in <pages>/_meta.ts, whose middleware runs on every route
text
HAMUR_E1246 <file>: a file name no longer limits a route middleware to the browser; drop .client and start the middleware with if (import.meta.server) return
text
HAMUR_E1246 <file>: a file name no longer limits a route middleware to the server, and a route middleware runs in the browser on client navigations; drop .server and check the request in server middleware (server/index.ts) or in the handler
text
HAMUR_E1246 <file>: a number prefix no longer orders route middleware; drop it and write the middleware in meta.middleware in the order it runs

Cause

A file in app/middleware/ of the app or a layer ends in .global, .client or .server, or starts with a number. Route middleware are functions a page imports, so nothing reads scope, side or order from a file name, and the file would not run.

Fix

Rename the file without the suffix or prefix and import it where it runs: app/pages/_meta.ts for every route, in the order it runs; return early with if (import.meta.server) return for the browser only.