Next.js Server Actions Configuration

Configure Next.js Server Actions with allowed origins and body size limits.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/rylezhou/arlis --skill next-js-server-actions-configuration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Next.js Server Actions Configuration
Source: https://github.com/rylezhou/arlis/tree/main/.agent/skills/nextjs16-server-actions
Command: npx skills add https://github.com/rylezhou/arlis --skill next-js-server-actions-configuration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides options to configure the behavior of Server Actions in your Next.js application, enhancing security and resource management.

Core Features & Use Cases

  • allowedOrigins: Specify trusted domains to prevent Cross-Site Request Forgery (CSRF) attacks by ensuring Server Actions are invoked only from secure origins.
  • bodySizeLimit: Control the maximum request body size to prevent excessive resource consumption and potential Denial-of-Service (DoS) attacks.
  • Enabling Server Actions: Configure Server Actions for earlier versions of Next.js.
  • Use Case: Securely configure your Next.js application to allow Server Actions to be invoked from a specific proxy domain while also setting a custom limit for request body sizes to optimize performance.

Quick Start

Configure your next.config.js file to set the bodySizeLimit for Server Actions to '2mb'.

Frequently Asked Questions about Next.js Server Actions Configuration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Next.js Server Actions to prevent CSRF attacks?

Preventing CSRF attacks with Next.js Server Actions involves configuring the `allowedOrigins` option in your `next.config.js` file to restrict invocations strictly to trusted proxy domains.

How do I set a request body size limit for Next.js Server Actions?

Setting a request body size limit for Next.js Server Actions requires modifying the `bodySizeLimit` option in the `next.config.js` file to prevent excessive resource consumption and mitigate Denial-of-Service attacks.

What is the purpose of allowedOrigins in Next.js Server Actions?

The `allowedOrigins` setting in Next.js Server Actions specifies trusted domains to ensure actions are invoked securely, preventing Cross-Site Request Forgery (CSRF) attacks from unauthorized external origins.

Do I need to modify next.config.js to enable Server Actions in older Next.js versions?

Yes, enabling Server Actions in earlier versions of Next.js requires modifying the `next.config.js` file to implement the necessary experimental `serverActions` settings for your application.

How do I secure Next.js Server Actions when using a proxy domain?

To secure Next.js Server Actions behind a proxy domain, modify your `next.config.js` file to configure `allowedOrigins` with the specific proxy domain while setting a custom `bodySizeLimit` to optimize performance.