Next.js Discord

Discord Forum

Next Redirect inside a server action

Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Open in Discord
Australian Freshwater CrocodileOP
I have a "use server"helper file, that I use in server components, mainly it's a wrapper around my api caller that injects headers and handle api errors and common responses

for certain api responses, I perform a logout, and redirect to login page

so first I delete the auth cookies, and then I use redirect('/login')

- First issue deleting cookies is not working, tries using the next cookies() function and I tried cookies-next library both failed
I found a way to fix that (buy adding a query param catched by the middleware), but I would like to know what's wrong with that

- Second issue as per next docs, redirect throw an error, and I'm fine with that, but it's spamming my company datadog with multi line errors including the stack trace and this happens with notFound() too and other internal next thrown errors,
I want to intercept these and transform them to a one line json errors,
any idea how to do that ?

here's the chunk of code in the "use server" file

1 Reply

Australian Freshwater CrocodileOP
here's an example of how the multi line next error in datadog