Unverified Commit a9870df1 authored by 최지원's avatar 최지원 Committed by GitHub

feat: add body parser limit for server actions (#51104)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?
Add configuration options to modify the `bodyParser` size as it used to
be available in Page Router.
### Why?
Server Actions "Error: Body exceeded 1mb limit" cannot be resolved since
the body-parser limit size is hardcoded to `1mb`.
### How?

Closes NEXT-
Fixes #

-->

### What?

Add configuration options to modify the `bodyParser` size as it used to
be available in Page Router for APIs.

```js
export const config = {
  api: {
    responseLimit: false | '8mb' 
  },
}
```

Reference: [API Routes Response Size
Limit](https://nextjs.org/docs/messages/api-routes-response-size-limit)

### Why?

Server Actions "Error: Body exceeded 1mb limit" cannot be resolved since
the body-parser limit size is hardcoded to `1mb`.

```js
// /packages/next/src/server/app-render/action-handler.ts

// ...
const actionData = (await parseBody(req, '1mb')) || ''
// ...
```

Reference:
https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/action-handler.ts#L355
### How?

- Added option "serverActionsLimit" as `SizeLimit` type to
`config-shared.ts`
- Modified `action-handler.ts` to validate `serverActions` &
`serverActionsLimit` options in nextConfig
- Added conditional `serverActionsLimit` value and `1mb` if falsy

**Working on testing**

Fixes #49891 | #51097 | #51099

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
Co-authored-by: 's avatarShu Ding <g@shud.in>
parent 916e21f9
...@@ -377,6 +377,7 @@ export function getEdgeServerEntry(opts: { ...@@ -377,6 +377,7 @@ export function getEdgeServerEntry(opts: {
middlewareConfig: Buffer.from( middlewareConfig: Buffer.from(
JSON.stringify(opts.middlewareConfig || {}) JSON.stringify(opts.middlewareConfig || {})
).toString('base64'), ).toString('base64'),
serverActionsSizeLimit: opts.config.experimental.serverActionsSizeLimit,
} }
return { return {
......
...@@ -773,8 +773,8 @@ export default async function getBaseWebpackConfig( ...@@ -773,8 +773,8 @@ export default async function getBaseWebpackConfig(
const hasServerComponents = hasAppDir const hasServerComponents = hasAppDir
const disableOptimizedLoading = true const disableOptimizedLoading = true
const enableTypedRoutes = !!config.experimental.typedRoutes && hasAppDir const enableTypedRoutes = !!config.experimental.typedRoutes && hasAppDir
const serverActions = !!config.experimental.serverActions && hasAppDir const useServerActions = !!config.experimental.serverActions && hasAppDir
const bundledReactChannel = serverActions ? '-experimental' : '' const bundledReactChannel = useServerActions ? '-experimental' : ''
if (isClient) { if (isClient) {
if ( if (
...@@ -2418,7 +2418,7 @@ export default async function getBaseWebpackConfig( ...@@ -2418,7 +2418,7 @@ export default async function getBaseWebpackConfig(
appDir, appDir,
dev, dev,
isEdgeServer, isEdgeServer,
useServerActions: serverActions, useServerActions,
})), })),
hasAppDir && hasAppDir &&
!isClient && !isClient &&
......
import type webpack from 'webpack' import type webpack from 'webpack'
import type { SizeLimit } from '../../../../../types'
import { getModuleBuildInfo } from '../get-module-build-info' import { getModuleBuildInfo } from '../get-module-build-info'
import { WEBPACK_RESOURCE_QUERIES } from '../../../../lib/constants' import { WEBPACK_RESOURCE_QUERIES } from '../../../../lib/constants'
import { stringifyRequest } from '../../stringify-request' import { stringifyRequest } from '../../stringify-request'
...@@ -21,6 +23,7 @@ export type EdgeSSRLoaderQuery = { ...@@ -21,6 +23,7 @@ export type EdgeSSRLoaderQuery = {
incrementalCacheHandlerPath?: string incrementalCacheHandlerPath?: string
preferredRegion: string | string[] | undefined preferredRegion: string | string[] | undefined
middlewareConfig: string middlewareConfig: string
serverActionsSizeLimit?: SizeLimit
} }
/* /*
...@@ -54,6 +57,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> = ...@@ -54,6 +57,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
incrementalCacheHandlerPath, incrementalCacheHandlerPath,
preferredRegion, preferredRegion,
middlewareConfig: middlewareConfigBase64, middlewareConfig: middlewareConfigBase64,
serverActionsSizeLimit,
} = this.getOptions() } = this.getOptions()
const middlewareConfig: MiddlewareConfig = JSON.parse( const middlewareConfig: MiddlewareConfig = JSON.parse(
...@@ -173,6 +177,11 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> = ...@@ -173,6 +177,11 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
reactLoadableManifest, reactLoadableManifest,
clientReferenceManifest: ${isServerComponent} ? rscManifest : null, clientReferenceManifest: ${isServerComponent} ? rscManifest : null,
serverActionsManifest: ${isServerComponent} ? rscServerManifest : null, serverActionsManifest: ${isServerComponent} ? rscServerManifest : null,
serverActionsSizeLimit: ${isServerComponent} ? ${
typeof serverActionsSizeLimit === 'undefined'
? 'undefined'
: JSON.stringify(serverActionsSizeLimit)
} : undefined,
subresourceIntegrityManifest, subresourceIntegrityManifest,
config: ${stringifiedConfig}, config: ${stringifiedConfig},
buildId: ${JSON.stringify(buildId)}, buildId: ${JSON.stringify(buildId)},
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
import { SERVER_RUNTIME } from '../../../../lib/constants' import { SERVER_RUNTIME } from '../../../../lib/constants'
import { PrerenderManifest } from '../../..' import { PrerenderManifest } from '../../..'
import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'
import { SizeLimit } from '../../../../../types'
export function getRender({ export function getRender({
dev, dev,
...@@ -31,6 +32,7 @@ export function getRender({ ...@@ -31,6 +32,7 @@ export function getRender({
clientReferenceManifest, clientReferenceManifest,
subresourceIntegrityManifest, subresourceIntegrityManifest,
serverActionsManifest, serverActionsManifest,
serverActionsSizeLimit,
config, config,
buildId, buildId,
nextFontManifest, nextFontManifest,
...@@ -51,6 +53,7 @@ export function getRender({ ...@@ -51,6 +53,7 @@ export function getRender({
subresourceIntegrityManifest?: Record<string, string> subresourceIntegrityManifest?: Record<string, string>
clientReferenceManifest?: ClientReferenceManifest clientReferenceManifest?: ClientReferenceManifest
serverActionsManifest: any serverActionsManifest: any
serverActionsSizeLimit?: SizeLimit
appServerMod: any appServerMod: any
config: NextConfigComplete config: NextConfigComplete
buildId: string buildId: string
...@@ -85,6 +88,7 @@ export function getRender({ ...@@ -85,6 +88,7 @@ export function getRender({
disableOptimizedLoading: true, disableOptimizedLoading: true,
clientReferenceManifest, clientReferenceManifest,
serverActionsManifest, serverActionsManifest,
serverActionsSizeLimit,
}, },
renderToHTML, renderToHTML,
incrementalCacheHandler, incrementalCacheHandler,
......
...@@ -30,12 +30,14 @@ import { ...@@ -30,12 +30,14 @@ import {
import { traverseModules, forEachEntryModule } from '../utils' import { traverseModules, forEachEntryModule } from '../utils'
import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep' import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'
import { getProxiedPluginState } from '../../build-context' import { getProxiedPluginState } from '../../build-context'
import { SizeLimit } from '../../../../types'
interface Options { interface Options {
dev: boolean dev: boolean
appDir: string appDir: string
isEdgeServer: boolean isEdgeServer: boolean
useServerActions: boolean useServerActions: boolean
serverActionsSizeLimit?: SizeLimit
} }
const PLUGIN_NAME = 'ClientEntryPlugin' const PLUGIN_NAME = 'ClientEntryPlugin'
...@@ -151,6 +153,7 @@ export class ClientReferenceEntryPlugin { ...@@ -151,6 +153,7 @@ export class ClientReferenceEntryPlugin {
appDir: string appDir: string
isEdgeServer: boolean isEdgeServer: boolean
useServerActions: boolean useServerActions: boolean
serverActionsSizeLimit?: SizeLimit
assetPrefix: string assetPrefix: string
constructor(options: Options) { constructor(options: Options) {
...@@ -158,6 +161,7 @@ export class ClientReferenceEntryPlugin { ...@@ -158,6 +161,7 @@ export class ClientReferenceEntryPlugin {
this.appDir = options.appDir this.appDir = options.appDir
this.isEdgeServer = options.isEdgeServer this.isEdgeServer = options.isEdgeServer
this.useServerActions = options.useServerActions this.useServerActions = options.useServerActions
this.serverActionsSizeLimit = options.serverActionsSizeLimit
this.assetPrefix = !this.dev && !this.isEdgeServer ? '../' : '' this.assetPrefix = !this.dev && !this.isEdgeServer ? '../' : ''
} }
......
...@@ -472,6 +472,7 @@ export default async function exportApp( ...@@ -472,6 +472,7 @@ export default async function exportApp(
largePageDataBytes: nextConfig.experimental.largePageDataBytes, largePageDataBytes: nextConfig.experimental.largePageDataBytes,
serverComponents: options.hasAppDir, serverComponents: options.hasAppDir,
hasServerComponents: options.hasAppDir, hasServerComponents: options.hasAppDir,
serverActionsSizeLimit: nextConfig.experimental.serverActionsSizeLimit,
nextFontManifest: require(join( nextFontManifest: require(join(
distDir, distDir,
'server', 'server',
......
...@@ -5,6 +5,7 @@ import type { ...@@ -5,6 +5,7 @@ import type {
ServerResponse, ServerResponse,
} from 'http' } from 'http'
import type { WebNextRequest } from '../base-http/web' import type { WebNextRequest } from '../base-http/web'
import type { SizeLimit } from '../../../types'
import { import {
ACTION, ACTION,
...@@ -245,6 +246,7 @@ export async function handleAction({ ...@@ -245,6 +246,7 @@ export async function handleAction({
generateFlight, generateFlight,
staticGenerationStore, staticGenerationStore,
requestStore, requestStore,
serverActionsSizeLimit,
}: { }: {
req: IncomingMessage req: IncomingMessage
res: ServerResponse res: ServerResponse
...@@ -258,6 +260,7 @@ export async function handleAction({ ...@@ -258,6 +260,7 @@ export async function handleAction({
}) => Promise<RenderResult> }) => Promise<RenderResult>
staticGenerationStore: StaticGenerationStore staticGenerationStore: StaticGenerationStore
requestStore: RequestStore requestStore: RequestStore
serverActionsSizeLimit?: SizeLimit
}): Promise<undefined | RenderResult | 'not-found'> { }): Promise<undefined | RenderResult | 'not-found'> {
let actionId = req.headers[ACTION.toLowerCase()] as string let actionId = req.headers[ACTION.toLowerCase()] as string
const contentType = req.headers['content-type'] const contentType = req.headers['content-type']
...@@ -372,7 +375,9 @@ export async function handleAction({ ...@@ -372,7 +375,9 @@ export async function handleAction({
} else { } else {
const { parseBody } = const { parseBody } =
require('../api-utils/node') as typeof import('../api-utils/node') require('../api-utils/node') as typeof import('../api-utils/node')
const actionData = (await parseBody(req, '1mb')) || ''
const actionData =
(await parseBody(req, serverActionsSizeLimit ?? '1mb')) || ''
if (isURLEncodedAction) { if (isURLEncodedAction) {
const formData = formDataFromSearchQueryString(actionData) const formData = formDataFromSearchQueryString(actionData)
......
...@@ -156,6 +156,7 @@ export async function renderToHTMLOrFlight( ...@@ -156,6 +156,7 @@ export async function renderToHTMLOrFlight(
nextFontManifest, nextFontManifest,
supportsDynamicHTML, supportsDynamicHTML,
nextConfigOutput, nextConfigOutput,
serverActionsSizeLimit,
} = renderOpts } = renderOpts
const appUsingSizeAdjust = nextFontManifest?.appUsingSizeAdjust const appUsingSizeAdjust = nextFontManifest?.appUsingSizeAdjust
...@@ -1606,6 +1607,7 @@ export async function renderToHTMLOrFlight( ...@@ -1606,6 +1607,7 @@ export async function renderToHTMLOrFlight(
generateFlight, generateFlight,
staticGenerationStore, staticGenerationStore,
requestStore, requestStore,
serverActionsSizeLimit,
}) })
if (actionRequestResult === 'not-found') { if (actionRequestResult === 'not-found') {
......
import type { LoadComponentsReturnType } from '../load-components' import type { LoadComponentsReturnType } from '../load-components'
import type { ServerRuntime } from '../../../types' import type { ServerRuntime, SizeLimit } from '../../../types'
import { NextConfigComplete } from '../../server/config-shared'
import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin' import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'
import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin' import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'
...@@ -138,6 +139,14 @@ export type RenderOptsPartial = { ...@@ -138,6 +139,14 @@ export type RenderOptsPartial = {
originalPathname?: string originalPathname?: string
isDraftMode?: boolean isDraftMode?: boolean
deploymentId?: string deploymentId?: string
loadConfig?: (
phase: string,
dir: string,
customConfig?: object | null,
rawConfig?: boolean,
silent?: boolean
) => Promise<NextConfigComplete>
serverActionsSizeLimit?: SizeLimit
} }
export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial export type RenderOpts = LoadComponentsReturnType & RenderOptsPartial
...@@ -19,7 +19,7 @@ import { ...@@ -19,7 +19,7 @@ import {
normalizeRepeatedSlashes, normalizeRepeatedSlashes,
MissingStaticPage, MissingStaticPage,
} from '../shared/lib/utils' } from '../shared/lib/utils'
import type { PreviewData, ServerRuntime } from 'next/types' import type { PreviewData, ServerRuntime, SizeLimit } from 'next/types'
import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin'
import type { OutgoingHttpHeaders } from 'http2' import type { OutgoingHttpHeaders } from 'http2'
import type { BaseNextRequest, BaseNextResponse } from './base-http' import type { BaseNextRequest, BaseNextResponse } from './base-http'
...@@ -255,6 +255,7 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -255,6 +255,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
supportsDynamicHTML?: boolean supportsDynamicHTML?: boolean
isBot?: boolean isBot?: boolean
clientReferenceManifest?: ClientReferenceManifest clientReferenceManifest?: ClientReferenceManifest
serverActionsSizeLimit?: SizeLimit
serverActionsManifest?: any serverActionsManifest?: any
nextFontManifest?: NextFontManifest nextFontManifest?: NextFontManifest
renderServerComponentData?: boolean renderServerComponentData?: boolean
...@@ -1650,6 +1651,8 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -1650,6 +1651,8 @@ export default abstract class Server<ServerOptions extends Options = Options> {
incrementalCache, incrementalCache,
isRevalidate: isSSG, isRevalidate: isSSG,
originalPathname: components.ComponentMod.originalPathname, originalPathname: components.ComponentMod.originalPathname,
serverActionsSizeLimit:
this.nextConfig.experimental.serverActionsSizeLimit,
} }
: {}), : {}),
isDataReq, isDataReq,
......
...@@ -304,6 +304,16 @@ const configSchema = { ...@@ -304,6 +304,16 @@ const configSchema = {
serverActions: { serverActions: {
type: 'boolean', type: 'boolean',
}, },
serverActionsSizeLimit: {
oneOf: [
{
type: 'number',
},
{
type: 'string',
},
] as any,
},
extensionAlias: { extensionAlias: {
type: 'object', type: 'object',
}, },
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
import { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin' import { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'
import { WEB_VITALS } from '../shared/lib/utils' import { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta' import type { NextParsedUrlQuery } from './request-meta'
import { SizeLimit } from '../../types'
export type NextConfigComplete = Required<NextConfig> & { export type NextConfigComplete = Required<NextConfig> & {
images: Required<ImageConfigComplete> images: Required<ImageConfigComplete>
...@@ -281,6 +282,11 @@ export interface ExperimentalConfig { ...@@ -281,6 +282,11 @@ export interface ExperimentalConfig {
* Enable `react@experimental` channel for the `app` directory. * Enable `react@experimental` channel for the `app` directory.
*/ */
serverActions?: boolean serverActions?: boolean
/**
* Allows adjusting body parser size limit for server actions.
*/
serverActionsSizeLimit?: SizeLimit
} }
export type ExportPathMap = { export type ExportPathMap = {
......
...@@ -416,6 +416,17 @@ function assignDefaults( ...@@ -416,6 +416,17 @@ function assignDefaults(
result.output = 'standalone' result.output = 'standalone'
} }
if (typeof result.experimental?.serverActionsSizeLimit !== 'undefined') {
const value = parseInt(
result.experimental.serverActionsSizeLimit.toString()
)
if (isNaN(value) || value < 1) {
throw new Error(
'Server Actions Size Limit must be a valid number or filesize format lager than 1MB: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions'
)
}
}
warnOptionHasBeenMovedOutOfExperimental( warnOptionHasBeenMovedOutOfExperimental(
result, result,
'transpilePackages', 'transpilePackages',
......
...@@ -23,6 +23,7 @@ import type { ...@@ -23,6 +23,7 @@ import type {
GetStaticProps, GetStaticProps,
PreviewData, PreviewData,
ServerRuntime, ServerRuntime,
SizeLimit,
} from 'next/types' } from 'next/types'
import type { UnwrapPromise } from '../lib/coalesced-function' import type { UnwrapPromise } from '../lib/coalesced-function'
import type { ReactReadableStream } from './stream-utils/node-web-streams-helper' import type { ReactReadableStream } from './stream-utils/node-web-streams-helper'
...@@ -260,6 +261,7 @@ export type RenderOptsPartial = { ...@@ -260,6 +261,7 @@ export type RenderOptsPartial = {
isBot?: boolean isBot?: boolean
runtime?: ServerRuntime runtime?: ServerRuntime
serverComponents?: boolean serverComponents?: boolean
serverActionsSizeLimit?: SizeLimit
customServer?: boolean customServer?: boolean
crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined
images: ImageConfigComplete images: ImageConfigComplete
......
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
const CONFIG_ERROR =
'Server Actions Size Limit must be a valid number or filesize format lager than 1MB'
createNextDescribe(
'app-dir action size limit invalid config',
{
files: __dirname,
skipDeployment: true,
dependencies: {
react: 'latest',
'react-dom': 'latest',
'server-only': 'latest',
},
},
({ next, isNextStart, isNextDeploy }) => {
if (!isNextStart) {
it('skip test for dev mode', () => {})
return
}
it('should error if serverActionsSizeLimit config is a negative number', async function () {
await next.patchFile(
'next.config.js',
`
module.exports = {
experimental: {
serverActions: true,
serverActionsSizeLimit: -3000,
},
}
`
)
await next.stop()
try {
await next.build()
} catch {}
expect(next.cliOutput).toContain(CONFIG_ERROR)
})
it('should error if serverActionsSizeLimit config is invalid', async function () {
await next.patchFile(
'next.config.js',
`
module.exports = {
experimental: {
serverActions: true,
serverActionsSizeLimit: 'testmb',
},
}
`
)
await next.stop()
try {
await next.build()
} catch {}
expect(next.cliOutput).toContain(CONFIG_ERROR)
})
it('should error if serverActionsSizeLimit config is a negative size', async function () {
await next.patchFile(
'next.config.js',
`
module.exports = {
experimental: {
serverActions: true,
serverActionsSizeLimit: '-3000mb',
},
}
`
)
await next.stop()
try {
await next.build()
} catch {}
expect(next.cliOutput).toContain(CONFIG_ERROR)
})
if (!isNextDeploy) {
it('should respect the size set in serverActionsSizeLimit', async function () {
await next.patchFile(
'next.config.js',
`
module.exports = {
experimental: {
serverActions: true,
serverActionsSizeLimit: '1.5mb',
},
}
`
)
await next.build()
await next.start()
const logs: string[] = []
next.on('stdout', (log) => {
logs.push(log)
})
next.on('stderr', (log) => {
logs.push(log)
})
const browser = await next.browser('/file')
await browser.elementByCss('#size-1mb').click()
await check(() => {
return logs.some((log) => log.includes('size = 1048576')) ? 'yes' : ''
}, 'yes')
await browser.elementByCss('#size-2mb').click()
await check(() => {
return logs.some((log) =>
log.includes('Error: Body exceeded 1.5mb limit')
)
? 'yes'
: ''
}, 'yes')
})
}
}
)
'use client'
export default function Form({ action }) {
const submit = (n) => action('a'.repeat(1024 * 1024 * n))
return (
<>
<button id="size-1mb" onClick={() => submit(1)}>
1mb
</button>
<button id="size-2mb" onClick={() => submit(2)}>
2mb
</button>
</>
)
}
import Form from './form'
async function action(payload = '') {
'use server'
console.log('size =', payload.length)
}
export default function Page() {
return <Form action={action} />
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment