Next.js Discord

Discord Forum

fetch & cookies are undefined before manually refreshing the page.

Unanswered
Fila Brasileiro posted this in #help-forum
Open in Discord
Fila BrasileiroOP
When redirecting to the checkout page I want to make a POST request to Klarna and then display their checkout html snippet. I also want to get cookies since I'm saving the cart in there. When I redirect through the Link tag from Next it doesn't work, same with anchor tags. It does work if I directly surf to localhost:3000/checkout or if I refresh the page after going there through the link.

The Link tag is placed in a client side component.

Then I've got a component for Klarna placed in the checkout page. It's server side since the POST request need to be made on the server.
I make a POST request to /api/checkout
where I send the cookies with, then I return the KlarnaResponse.

Also something I noticed, after I refresh the page and it "works" I'm getting an error message:

Warning: Prop dangerouslySetInnerHTML did not match. Server: (the html_snippet from klarna).

I haven't tried alot since I'm pretty lost, I did try changing the Link to anchor tags, removing prefetch etc. but nothing really works.

1 Reply

Fila BrasileiroOP
I changed to anchor tags and it does seem to work, but I'm still getting the error implying that Warning: Prop dangerouslySetInnerHTML did not match. Server: "<div...........