I encountered a bug while attempting to write a middleware while using filesystem-based routing that caused requests to API routes to fail.
My app defined a middleware to run on all routes in the file routes/_middleware.ts. When an island attempted to call an API endpoint under routes/api/, the request failed with the following error on the server:
Error: Expected a route, middleware, layout or error template, but couldn't find relevant exports in: undefined
I was able to create a minimal reproduction by simply adding a _middleware.ts file to the Fresh starter app (GitHub).
A workaround is possible by switching to programmatic routing rather than filesystem routing (example).
I am using Fresh v2.2.0 and Deno v2.5.6.
I encountered a bug while attempting to write a middleware while using filesystem-based routing that caused requests to API routes to fail.
My app defined a middleware to run on all routes in the file
routes/_middleware.ts. When an island attempted to call an API endpoint underroutes/api/, the request failed with the following error on the server:I was able to create a minimal reproduction by simply adding a
_middleware.tsfile to the Fresh starter app (GitHub).A workaround is possible by switching to programmatic routing rather than filesystem routing (example).
I am using Fresh v2.2.0 and Deno v2.5.6.