Ive just added NextJS server actions to a project for some cookie creation, and my forms have stopped submitting. I get a LamdaTimeout error.
Is it possible to have both Netlify form, and NextJS server actions?
Ive just added NextJS server actions to a project for some cookie creation, and my forms have stopped submitting. I get a LamdaTimeout error.
Is it possible to have both Netlify form, and NextJS server actions?
Yes, if you make sure to make a POST request to a URL that’s not handled by your server action like /favicon.ico for example.
Yeah they don’t, the forms post to ‘/?no-cache=1’ and the server actions don’t post. I just use them to create a cookie like below.
`'use server';
import { cookies } from 'next/headers';
export async function createCookie(name: string, value: string, date: Date) {
cookies().set(name, value, { secure: true, expires: date });
}`
Isn’t that just your home page?
Technically yes, I was following the form guides when setting them up. Does the post url have to be a page that doesnt exist? I thought it didnt really matter as the the form name will get picked up in the request body.
It has to be a page that exists as a static page. [Support Guide] Form problems, form debugging, 404 when submitting
Well it is a SSR rendered page via Nextjs, the forms are only a problem when I add the server actions. They work fine the rest of the time.
As I mentiond before, that’s vey likely the problem. Forms cannot post to a dynamic page. You can only post to a static asset to receive form submissions.
That seems to work thank you, I pointed the fetch request to a static html page in my public folder. The docs should be updated to specify that as its good to know.
Thanks again for the help.