SolidJSS
SolidJSโ€ข2y agoโ€ข
15 replies
TheKnightCoder

"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>
  )
}


~/lib/server/auth
import { cache } from "@solidjs/router";

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

  console.log("getAuth")
  return {
    user: {
      email: 'test@test.com',
    }
  }
}, 'getAuth')


---
deployed on cloudflare

  server: {
    preset: 'cloudflare-pages',
    unenv: cloudflare,

    rollupConfig: {
      external: ['__STATIC_CONTENT_MANIFEST', 'node:async_hooks'],
    },
  },
  middleware: './src/middleware.ts',
  ssr: false,
Was this page helpful?