正在加载视频...

视频加载失败

Secure your server actions

75,025 次观看 • 11 个月前 •via X (Twitter)

10 条评论

Alex Sidorenko 的头像
Alex Sidorenko11 个月前

Nuance: action ID is a unique hash. If you don't render it (like in the example when the user is not an admin), it would be hard to trigger your endpoint But in any case, server actions always create endpoints, and endpoints should be protected

Eduardo Borges 的头像
Eduardo Borges11 个月前

damn... i probably missed that one in some project though I try to keep the actions inside a ./actions/delete-stuff.ts with 'use server' works right?

Alex Sidorenko 的头像
Alex Sidorenko11 个月前

"use server" only ensures that the code in marked file never gets into the client-side js bundle You still need to protect your server actions as if they are separate callable endpoints (because they are)

Iaci 的头像
Iaci11 个月前

I (who separates front- and backend) dont understand this

Ᵽøłskɨ Ƀøɍsȼħ 的头像
Ᵽøłskɨ Ƀøɍsȼħ11 个月前

...or next-safe-action does this trick for you 😉

yo puaaa 👋 的头像
yo puaaa 👋11 个月前

Too many people thought server actions were a magic black box that just made things work, without realizing it's just magic POST calls!

Daniel Still 的头像
Daniel Still11 个月前

I love Next overall, but it's a way better experience to just use Route Handlers. Especially if you plugin a framework like Hono or Elysia for good conventions and plugins out of the box.

Legion Dev 的头像
Legion Dev11 个月前

well its same like secure your api end point lol

Ruchir 的头像
Ruchir11 个月前

I wonder how many security issues modern Next has created due to server actions lol.

Aurora Scharff 的头像
Aurora Scharff11 个月前

Also this

相关视频