Skip to content

Using Middlewares #80

Answered by lazarv
mrose asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mrose!

.middleware.ts (starting with a dot) is only the extension of the file, so it's either middleware.ts or name.middleware.ts, where name is not affecting on which route the middleware is active, but only to help you navigate in your project and put your middleware logic in multiple files. You can use the useMatch function from @lazarv/react-server/router to check if your current pathname should be processed in the middleware. See an example in the docs app at https://github.com/lazarv/react-server/blob/main/docs/src/pages/i18n.middleware.mjs, but even the docs is proposing this approach at https://react-server.dev/router/middlewares.

I understand that this is misleading, and this…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mrose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants