Skip to content

Commit 4d0357e

Browse files
zhengkylLadyBluenoteskodiakhq[bot]
authored
add deferStream: true to auth code example (#1385)
Co-authored-by: Sarah <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 0ec7a1e commit 4d0357e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/routes/solid-start/advanced/auth.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ const getPrivatePosts = query(async function() {
5050
})
5151

5252
export default function Page() {
53-
const posts = createAsync(() => getPrivatePosts());
53+
const posts = createAsync(() => getPrivatePosts(), { deferStream: true });
5454
}
5555
```
5656

5757
Once the user hits this route, the router will attempt to fetch `getPrivatePosts` data.
5858
If the user is not signed in, `getPrivatePosts` will throw and the router will redirect to the login page.
59+
60+
To prevent errors when opening the page directly, set `deferStream: true`.
61+
This would ensure `getPrivatePosts` resolves before the page loads since server-side redirects cannot occur after streaming has started.

0 commit comments

Comments
 (0)