Sounds like you found a thing that needs to happen on the client side.
JavaScript
Are you using NextJS with the app router, or with the pages router?
App router, where the directory structure controls the url.
For both frameworks, the directory structure controls the URL unless there's an exception I'm unaware of.
One way to forward the cookie may be to read cookies from the API response headers and write them using the following documentation: https://nextjs.org/docs/app/api-reference/functions/cookies
whereever you drop/manipulate the cookie (assuming its within your control) is where you'd have to add additional logic to handle that data SSR. if that external source is beyond your control you likely wont be able to sniff that cookie out (you can stack iframes potentially) and essentially 'monitor' the contents but not sure this is practical/effective