icanflyit
icanflyit
Explore posts from servers
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
Ok that sounds good, thanks so much :)
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
So as soon as that Navigate component is rendered it will navigate? (and if isLoggedIn() is initially true it won't navigate)
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
Also a more general js/ts question, with useNavigate, can I throw navigate() (returns void) if I don't want execution to continue? Or does an error have to be of an actual error type
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
So with a server function, will the client make a request to the solid start server (and all that code for the request is automated) and then the solid start server will make the request to the backend?
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
But there are times when the authentication will be done client side (like after logging in)
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
This is for an authentication guard (against an external server), since I have SSR the goal is that the authentication request is made from ssr and if it fails, it's redirected and the client never receives the page
13 replies
SSolidJS
Created by icanflyit on 8/4/2024 in #support
How to do client side redirects
does useNavigate work server side (and behave like redirect())
13 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
I have solid-devtools and tanstack query devtools so I'm not sure if one of those is changing error handling (or if it's somewhere else in my project)
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
I'm still confused why my errors aren't being printed to console (Any error thrown inside a component shows an error on a screen but top level errors seem to just dissapear (and cause everything in that suspense to not render)
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
I have it all working now, thanks so much :)
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
Wait and when I use "use server", is that making an endpoint the client can call?
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
That makes a lot more sense lol
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
Wait is the idea that the lazy imports are not top level
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
How would I implement that here so that I only call it on the server without using use_server
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
But I'm never calling testFunc()
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
Now if I change the testFunc to not use "use server"
function testFunc() {
getCookie("test");
}
function testFunc() {
getCookie("test");
}
I get the same output from the server console (working correctly):
10:26:45 AM [vite] hmr update /Users/elliot/Code/Web/get-cookie/src/app.tsx
before import
after import
10:26:45 AM [vite] hmr update /Users/elliot/Code/Web/get-cookie/src/app.tsx
before import
after import
But I get an error in the browser console
client:495 [vite] connecting...
client:614 [vite] connected.
__vite-browser-external:node:async_hooks:3 Uncaught Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
at Object.get (__vite-browser-external:node:async_hooks:3:11)
at http.js?t=1721928177293&v=2b57a03b:4:166
get @ __vite-browser-external:node:async_hooks:3
(anonymous) @ http.js?t=1721928177293&v=2b57a03b:4
client:495 [vite] connecting...
client:614 [vite] connected.
__vite-browser-external:node:async_hooks:3 Uncaught Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
at Object.get (__vite-browser-external:node:async_hooks:3:11)
at http.js?t=1721928177293&v=2b57a03b:4:166
get @ __vite-browser-external:node:async_hooks:3
(anonymous) @ http.js?t=1721928177293&v=2b57a03b:4
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
Okay good to know, I noticed before import wasn't being called (but was with lazy importing)
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
When I load the page ssr works correctly and I get the following output from the server console:
10:23:15 AM [vite] hmr update /Users/elliot/Code/Web/get-cookie/src/app.tsx
before import
after import
10:23:15 AM [vite] hmr update /Users/elliot/Code/Web/get-cookie/src/app.tsx
before import
after import
And the page loads correctly on the client side too, I get the following output in my devtools console
client:495 [vite] connecting...
client:614 [vite] connected.
app.tsx:5 before import
app.tsx:5 after import
client:495 [vite] connecting...
client:614 [vite] connected.
app.tsx:5 before import
app.tsx:5 after import
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
Here's my bare app.tsx (setup like I originally had with "use server")
import { createSignal } from "solid-js";
import "./app.css";

console.log("before import");
import { getCookie } from "vinxi/http";
console.log("after import");

function testFunc() {
"use server";
getCookie("test");
}

export default function App() {
const [count, setCount] = createSignal(0);

return (
<main>
<h1>Hello world!</h1>
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
Clicks: {count()}
</button>
<p>
Visit{" "}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{" "}
to learn how to build SolidStart apps.
</p>
</main>
);
}
import { createSignal } from "solid-js";
import "./app.css";

console.log("before import");
import { getCookie } from "vinxi/http";
console.log("after import");

function testFunc() {
"use server";
getCookie("test");
}

export default function App() {
const [count, setCount] = createSignal(0);

return (
<main>
<h1>Hello world!</h1>
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
Clicks: {count()}
</button>
<p>
Visit{" "}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{" "}
to learn how to build SolidStart apps.
</p>
</main>
);
}
43 replies
SSolidJS
Created by icanflyit on 7/23/2024 in #support
SSR Cookies
I don't really understand how to figure out what triggers an error because there are no console logs (in the chrome dev console), I'm not quite sure why but I created an app to test from the bare template and I do get an error in console
43 replies