Working with cookies on localhost is a nightmare
Answered
American Wirehair posted this in #help-forum
American WirehairOP
This is not a nextjs-specific question, but undoubtedly one that 90%+ of developers here face. Cookies are bound to a domain. This means if I access nextjs on
localhost:3000, cookies will be for localhost. If I want to test against production servers at for example https://website.com/api, there's no way for me to send my localhost cookies to that domain. Editing the hosts file on Windows is not ideal either, because then website.com will point to localhost, and I won't be able to reach the production site. Other than creating an entirely new cloud environment for dev/testing (horrible feedback loop having to push changes, then "see what happens"...), what are my alternatives?Answered by American Wirehair
Oh wow, I can just use server actions and import them into the client component. The server action passes the cookie along
1 Reply
American WirehairOP
Oh wow, I can just use server actions and import them into the client component. The server action passes the cookie along
Answer