TanStackT
TanStack4w ago
4 replies
rubber-blue

Server Functions CORS issue?

My understanding from the docs is that the following its server code, which I could call from component, but I'm seeing CORS issues which led me to troubleshoot with the following code.
export const openGateServer = createServerFn()
  .inputValidator((data: { gateId: string }) => data)
  .handler(async ({ data }) => {
    console.log('========================================')
    console.log('SERVER FUNCTION CALLED')
    console.log(
      'Environment check - is this server?:',
      typeof window === 'undefined',
    )
    console.log('========================================')


// Calling it from a component like this.
const openGate = useServerFn(openGateServer)


Why I'm getting that the Environment check is server false, shouldn't this be running in the server?
Was this page helpful?