|
In SolidStart documentation : https://docs.solidjs.com/solid-start/advanced/auth I'm creating the project using this is the code in If I visit
I don't know if this is intentional or not. I appreciate any answers |
Replies: 3 comments
|
By using doing this cause redirect to always work even in manual URL change visit but since the documentation of the auth does not say anything about this, I won't mark this as answer yet |
|
I think the breaking point is the redirect commenting redirect and navigating between |
|
Adding In your code example, Without deferStream, when you visit the link directly, you have two responses from the server. The initial streamed html, and then data later in a second response. The redirect is done via a 302 Redirect using headers, but headers are already set in the initial response, hence the error message. With deferStream, the server waits until the query finishes before sending anything. No double headers. When you navigate using page links, there is client side navigation and no streaming. Only the data needs to be fetched so only one response. I created an issue for the docs because this is a common problem solidjs/solid-docs#1384 |
Adding
{ deferStream: true }is the answer.In your code example,
session.data.idis always undefined becausesession.datais you object you passeduseSession, so it always runs the redirect.Without deferStream, when you visit the link directly, you have two responses from the server. The initial streamed html, and then data later in a second response. The redirect is done via a 302 Redirect using headers, but headers are already set in the initial response, hence the error message.
With deferStream, the server waits until the query finishes before sending anything. No double headers.
When you navigate using page links, there is client side navigation and no streaming. Only the data needs…