Cant export dynamic in route handler
Answered
Dwarf Crocodile posted this in #help-forum
Dwarf CrocodileOP
When i try to export dynamic in a route handler
i get this error
export const dynamic = "force-dynamic";
export const GET = async (i get this error
Collecting page data ..Error: A "use server" file can only export async functions.Answered by joulev
then the issue is in a different file. check for all files with
"use server" and ensure that all of those files export exclusively async functions. synchronous functions, variables, classes are all not allowed, only async functions are allowed7 Replies
You are not supposed to add “use server” to server component and route handler files
Dwarf CrocodileOP
i dont have one thats the wierd part
@Dwarf Crocodile i dont have one thats the wierd part
then the issue is in a different file. check for all files with
"use server" and ensure that all of those files export exclusively async functions. synchronous functions, variables, classes are all not allowed, only async functions are allowedAnswer
Dwarf CrocodileOP
Oh i found it, is it possible to react cache an async function and return it as async?
export const validateLogin = cache(async () => {no... React.cache does basically nothing in a server action, why do you want to use it in an action?
Dwarf CrocodileOP
Oh no true i never use that as a server action i'll just remove the use server. Mixed up server only and use server my bad.