Is it possible to change the URI path of a server action?
Unanswered
Satin posted this in #help-forum
SatinOP
Fully describe what you're trying to accomplish
I have started to use server actions and my Next.js application logs every time it does a GET, POST, etc.
As we all know, server actions are invoked with a POST request.
I wanted to be able to use Next.js's
I'm guessing that maybe they use fetch under the hood, and so the logic of revalidatePath should work? But I don't know.
But I have noticed that the POST for invoking the server actions seems to be going to the page on which the server action is called.
But if I'm calling several Server Actions on the same page, they all appear as POSTs to that page URL.
So if e.g. I had a page on app/login and I invoked several server actions on that page, they appear as:
POST | http://localhost:3000/login (one server action)
POST | http://localhost:3000/login (another server action)
So I'm thinking that if revalidatePath even works with server actions, I won't be able to revalidate specific ones called from the same page.
So if indeed we can use revalidatePath with server actions, and I wanted to just revaliate one of the actions and it's possible - how would I do it?
I have started to use server actions and my Next.js application logs every time it does a GET, POST, etc.
As we all know, server actions are invoked with a POST request.
I wanted to be able to use Next.js's
revalidatePath with these server action invocations (if possible or if I still get the benefit).I'm guessing that maybe they use fetch under the hood, and so the logic of revalidatePath should work? But I don't know.
But I have noticed that the POST for invoking the server actions seems to be going to the page on which the server action is called.
But if I'm calling several Server Actions on the same page, they all appear as POSTs to that page URL.
So if e.g. I had a page on app/login and I invoked several server actions on that page, they appear as:
POST | http://localhost:3000/login (one server action)
POST | http://localhost:3000/login (another server action)
So I'm thinking that if revalidatePath even works with server actions, I won't be able to revalidate specific ones called from the same page.
So if indeed we can use revalidatePath with server actions, and I wanted to just revaliate one of the actions and it's possible - how would I do it?