Passing variables from client to getServerSideProps
Unanswered
Giant Chinchilla posted this in #help-forum
Giant ChinchillaOP
How would the folllowing scenario be handled in Next.js:
a user is authenticated with a JWT token
this token is passed to all external API requests
the user is also part of a workspace
this workspace id gets passed alongside the JWT token alongside each API request
each browser tab can have a different active workspace
So you can imagine each external api request has the following headers:
fetch(url, {
headers: {
'Authentication': 'Bearer token',
'x-workspace-id': '15'
}
})
Now my question:
What would be the best way to ensure that the x-workspace-id can be included in the request when the request is being made from the server-side?
I cannot use cookies as I need the functionality of each browser tab being able to have a different workspace open.
a user is authenticated with a JWT token
this token is passed to all external API requests
the user is also part of a workspace
this workspace id gets passed alongside the JWT token alongside each API request
each browser tab can have a different active workspace
So you can imagine each external api request has the following headers:
fetch(url, {
headers: {
'Authentication': 'Bearer token',
'x-workspace-id': '15'
}
})
Now my question:
What would be the best way to ensure that the x-workspace-id can be included in the request when the request is being made from the server-side?
I cannot use cookies as I need the functionality of each browser tab being able to have a different workspace open.