Starlight Route Data Middleware must not conflict with Astro's middleware #3017
Replies: 2 comments 3 replies
-
I think it would make sense to enforce it with a nice error in code so people clearly understand what to do when they hit it. Should be quite easy to do in our schema here: starlight/packages/starlight/utils/user-config.ts Lines 231 to 236 in 2f8cd17 Use |
Beta Was this translation helpful? Give feedback.
-
The validation was released in Starlight 0.32.6 🎉 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is your idea?
As @delucis noticed in Discord, the Starlight middleware must or may not conflict with the Astro middleware. In other words, the behaviour of the middleware is I think unpredictable and not investigated at the moment, if you create your Starlight middleware in
src/middleware.ts
. I would say, that we recommend against creating your custom route data inside a file that gets processed by Astro itself.There are a few point to consider here:
src/middleware.js|ts
orsrc/middleware/index.js|ts
? Eg throw a "Starlight middleware must not be located in {filePath}" error if the user tries to?Why is this important?
I don't know how severe the impacts are when you create your Starlight middleware under
src/middleware.ts
because it gets processed by Astro, but as Chris said, we must probably recommend against doing so.How does your idea relate to existing docs content?
No response
Participation
Beta Was this translation helpful? Give feedback.
All reactions