"use server" working locally but not when deployed

why does this code not work when deployed but works locally in dev? removing "use server" makes it work but for some reason when its there my output is just "Signed in as" logs also do not show that getAuth is running register.tsx
import { createAsync } from "@solidjs/router";
import { getAuth } from '~/lib/server/auth'


export default function Register() {
const auth = createAsync(() => getAuth(), { deferStream: true })

return (
<p>Signed in as {auth()?.user.email}</p>
)
}
import { createAsync } from "@solidjs/router";
import { getAuth } from '~/lib/server/auth'


export default function Register() {
const auth = createAsync(() => getAuth(), { deferStream: true })

return (
<p>Signed in as {auth()?.user.email}</p>
)
}
~/lib/server/auth
import { cache } from "@solidjs/router";

export const getAuth = cache(async () => {
"use server"

console.log("getAuth")
return {
user: {
}
}
}, 'getAuth')
import { cache } from "@solidjs/router";

export const getAuth = cache(async () => {
"use server"

console.log("getAuth")
return {
user: {
}
}
}, 'getAuth')
--- deployed on cloudflare
server: {
preset: 'cloudflare-pages',
unenv: cloudflare,

rollupConfig: {
external: ['__STATIC_CONTENT_MANIFEST', 'node:async_hooks'],
},
},
middleware: './src/middleware.ts',
ssr: false,
server: {
preset: 'cloudflare-pages',
unenv: cloudflare,

rollupConfig: {
external: ['__STATIC_CONTENT_MANIFEST', 'node:async_hooks'],
},
},
middleware: './src/middleware.ts',
ssr: false,
7 Replies
russellchoudhury
russellchoudhuryOP3mo ago
O, ssr: true seems to fix it... so i need ssr to run 'server actions'?
Jasmin
Jasmin3mo ago
yeah, ssr: false doesn't ship any server code
Jasmin
Jasmin3mo ago
oh my bad, sorry!
russellchoudhury
russellchoudhuryOP3mo ago
O okay, do you know why my code wasn't working when ssr is false? because my tanstack form don't work when ssr is true 😂 ok now it works with ssr false??? so weird, i don't even know what changed 🤔
Rodrigo
Rodrigo3mo ago
caching? refreshing? the time of the day? Maybe it's already August 27th where you are? not sure, but I've noticed more than the average random issues while dealing with solid-start also, please notice tanstack-forms is super new, they ought to have some issues of their own
russellchoudhury
russellchoudhuryOP3mo ago
well it was broken on the 26th and fixed on the 27th 😂 ... My middleware seemed to have caused some issues, maybe that was caching when i was debugging When SSR was false then this line would break things in the middleware
// Check user registration status and redirect if necessary
if (!pathname.startsWith('/auth/register') && !auth?.user.isRegistered) {
return sendRedirect(`/auth/register`, 302)
}
// Check user registration status and redirect if necessary
if (!pathname.startsWith('/auth/register') && !auth?.user.isRegistered) {
return sendRedirect(`/auth/register`, 302)
}
I think it would cause an infinite redirect loop which wouldn't happen when SSR is on adding && !pathname.startsWith('/_server') fixed this issue but i am sure i removed the middleware before and still had issues 🤷‍♂️ working now, hopefully i don't get any other issues like this because I really don't want to switch back to nextjs :L
Want results from more Discord servers?
Add your server