Server Action within an API Rout
Answered
Cuvier’s Dwarf Caiman posted this in #help-forum
Cuvier’s Dwarf CaimanOP
Howdy! Is it okay and safe to call a server action within an API route. I need to use an API route as the request body is too large for a server action, but I'd like to run some authorisation checks to my DB within the API call using an existing server action.
Answered by B33fb0n3
yes it's safe. The server action will be converted to a regular function and the route handler is handled serverside. But: make sure you also build your server action and route handler safe to prevent unexpected behaviour
3 Replies
@Cuvier’s Dwarf Caiman Howdy! Is it okay and safe to call a server action within an API route. I need to use an API route as the request body is too large for a server action, but I'd like to run some authorisation checks to my DB within the API call using an existing server action.
yes it's safe. The server action will be converted to a regular function and the route handler is handled serverside. But: make sure you also build your server action and route handler safe to prevent unexpected behaviour
Answer
Cuvier’s Dwarf CaimanOP
Thankyou!
Happy to help