Middleware and getServerSideProps
Answered
thedevkim posted this in #help-forum
Hello. I have a question. Which one do run first? Middleware or getServerSideProps ?
11 Replies
Answer
Hi. I have a question. How can i execute only once the middleware ? i see that it executes multiple times on one page load only.
@Ray
@Ray
@thedevkim Hi. I have a question. How can i execute only once the middleware ? i see that it executes multiple times on one page load only.
<@743561772069421169>
you could use matcher to control when should the middleware run
https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
@Ray you could use matcher to control when should the middleware run
https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
Got a question regarding matcher.
I have this config.
The middleware does not execute when the url is
But it does on
do you have any idea ?
export const config = {
matcher: "/data/shipments",
matcher: "/data/shipments/:path*",
matcher: "/data/shipments/:path*/edit",
};I have this config.
The middleware does not execute when the url is
/data/shipmentsBut it does on
/data/shipments/1 /data/shipments/1/editdo you have any idea ?
@thedevkim Got a question regarding matcher.
export const config = {
matcher: "/data/shipments",
matcher: "/data/shipments/:path*",
matcher: "/data/shipments/:path*/edit",
};
I have this config.
The middleware does not execute when the url is `/data/shipments`
But it does on
`/data/shipments/1`
`/data/shipments/1/edit`
do you have any idea ?
You should pass an array of string to it
@Ray You should pass an array of string to it
Hello. Got another question.
From middleware data. I want to pass a data from middlware to getServerProps so i can render it on my component.
Is it possible ?
From middleware data. I want to pass a data from middlware to getServerProps so i can render it on my component.
Is it possible ?
@thedevkim Hello. Got another question.
From middleware data. I want to pass a data from middlware to getServerProps so i can render it on my component.
Is it possible ?
not possible, they are running in different runtime
@Ray not possible, they are running in different runtime
Hmm do you have any idea on what should i do.
in my middleware i request permissions. I get data wether user have write or read on the screen. How can i pass it to the screen ?
in my middleware i request permissions. I get data wether user have write or read on the screen. How can i pass it to the screen ?