[Feature request] Exclude/detect on-demand revalidation request from/in middleware for authentication #35659
bennettdams
started this conversation in
Ideas
Replies: 1 comment
-
This was changed in See: #38562 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This was briefly discussed in the comments of this post, but without an answer.
Describe the feature you'd like to request
I'm using middlewares to protect sites from unauthenticated access. Unfortunately the new on-demand revalidation and its requests are also intercepted by the middleware.
In my case, unauthenticated users are redirected to the sign in page. Here's part of the middleware for reference:
I obviously don't want to do this redirection for the revalidation requests.
Right now, I circumvent this by looking at the header of the middleware request:
Requests coming from on-demand revalidation (
await res.unstable_revalidate("/some-path")
) will have this header. I can skip the redirection for such requests, but this is obviously not great.Is there a better way?
Describe the solution you'd like
Possible solutions I thought about:
Beta Was this translation helpful? Give feedback.
All reactions