Add cookie parameters like domain, path... to the request cookies in middleware.tsx #62799
sanskar-19
started this conversation in
Ideas
Replies: 1 comment
-
You can already, as seen here. response.cookies.set({
name: 'vercel',
value: 'fast',
path: '/',
}) |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
request.cookies.set()
include basic cookie attributes other than just name and value.Non-Goals
No response
Background
The problem that I am facing is cookie sharing across domains and subdomains which I have managed to implement on the client side (NextJS 14 App Router) but in the middleware, I get options for NextResponse to set, whilst not for NextRequest.
Since there is no provision to update tokens on the client from Page components so I am updating the auth tokens by validating on the middleware only.
If in case of invalid tokens, I am refreshing the same and likewise updating a few parameters.
By default if I set a cookie on
abc.com
it sets the domain parameter asabc.com
but to access on subdomains as well, I need the parameter as.abc.com
.Proposal
Add the options parameter to the request cookies in the middleware file.
Beta Was this translation helpful? Give feedback.
All reactions