An update to the "Pass Value from Middleware" blog post #1113
Closed
liamross
started this conversation in
Feature Requests
Replies: 1 comment
-
Actually I figured it out, it's this block: But I have no idea how this works, some sort of special header prefix that gets removed from the response by Next? |
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
-
The blog post in question
I'm trying to pass values from my middleware to my routes, and this blog post has been very helpful! However, when I look at the clerk source code it looks like it has evolved quite a bit since it was written. The new approach avoids setting the values in response headers. Specifically it looks like the values are being directly set on request?
https://github.com/clerkinc/javascript/blob/81928406a0a15de169e33ac5fd8f00d77831aa74/packages/nextjs/src/server/utils.ts#L10-L17
I tried this approach in my own code but can't seem to retrieve the values in my routes (this may very well be my own issue reproducing the clerk source code). Any plans to update / write a blog post about the new approach? It seems quite interesting and passing context from middleware to routes is definitely a huge missing part of NextJS.
Alternatively I'd just love to know if there's any specific tricks to enable passing the values correctly.
Beta Was this translation helpful? Give feedback.
All reactions