> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # Vercel에 Mastra 배포 사용`@mastra/deployer-vercel`Vercel에서 Mastra 서버를 서버리스 기능으로 배포합니다. 배포자는 코드를 번들로 묶고`.vercel/output`Vercel을 따르는 디렉토리[출력 API 빌드](https://vercel.com/docs/build-output-api/v3), 추가 구성 없이 배포 준비가 완료되었습니다. > **정보:** 이 가이드에서는[Mastra server](https://mastra.zisheng.pro/ko/docs/server/mastra-server). If you're using a [server adapter](https://mastra.zisheng.pro/ko/docs/server/server-adapters) or [web framework](https://mastra.zisheng.pro/ko/docs/deployment/web-framework), 해당 프레임워크에서 평소 사용하는 방식으로 배포합니다. ## 시작하기 전에 당신은[Mastra application](https://mastra.zisheng.pro/ko/guides/getting-started/quickstart) and a [Vercel](https://vercel.com/) account. > **경고:** Vercel Functions는 임시 파일 시스템을 사용하므로 구성하는 모든 스토리지(관측성 스토리지 포함)는 외부에서 호스팅되어야 합니다. 당신이 사용하는 경우[LibSQLStore](https://mastra.zisheng.pro/ko/reference/storage/libsql) 에서 파일 URL을 사용하는 경우 원격으로 호스팅되는 데이터베이스로 전환합니다. ## 설치 추가`@mastra/deployer-vercel` package to your project: **npm**: ```bash npm install @mastra/deployer-vercel@latest ``` **pnpm**: ```bash pnpm add @mastra/deployer-vercel@latest ``` **Yarn**: ```bash yarn add @mastra/deployer-vercel@latest ``` **Bun**: ```bash bun add @mastra/deployer-vercel@latest ``` 수입[`VercelDeployer`](https://mastra.zisheng.pro/ko/reference/deployer/vercel) 을 설치하고 Mastra 구성에서 deployer로 설정합니다: ```typescript import { Mastra } from '@mastra/core' import { VercelDeployer } from '@mastra/deployer-vercel' export const mastra = new Mastra({ deployer: new VercelDeployer(), }) ``` ## 배포 1. 프로젝트를 원격 Git Provider(예: GitHub)에 푸시하고 저장소를 Vercel에 연결하세요. 기본적으로 Vercel은 실행됩니다.`npm run build`, which triggers `mastra build`. If you don't have a build script, add `"build": "mastra build"` to your `package.json`. > **노트:** 애플리케이션을 실행하는 데 필요한 환경 변수(예:[model provider](https://mastra.zisheng.pro/ko/models/providers) API key). 2. 준비가 되면 다음을 클릭하세요.**Deploy** 을 클릭하고 첫 번째 배포가 완료될 때까지 기다립니다. 3. 배포를 확인하세요.`https://.vercel.app/api/agents`, Agent의 JSON 목록이 반환되어야 합니다. Mastra 서버는 모든 엔드포인트 앞에 다음을 붙입니다.`/api`, 요청할 때 URL에 이를 추가해야 합니다. 4. 이제 HTTP를 통해 Mastra 엔드포인트를 호출할 수 있습니다. > **경고:** 설정[authentication](https://mastra.zisheng.pro/ko/docs/server/auth) before exposing your endpoints publicly. ## 사진관 배포할 수 있습니다.[Studio](https://mastra.zisheng.pro/ko/docs/studio/overview) alongside your API by enabling the `studio` 옵션을 사용합니다. Studio는 Vercel의 Edge CDN에서 제공되는 정적 애셋으로 배포되므로 함수 호출을 소비하지 않습니다. ```typescript import { Mastra } from '@mastra/core' import { VercelDeployer } from '@mastra/deployer-vercel' export const mastra = new Mastra({ deployer: new VercelDeployer({ studio: true, }), }) ``` 배포 후 Studio는 루트 URL(`https://.vercel.app/`) and the API remains at `/api/*`. Studio는 동일한 origin의 API에 자동으로 연결되므로 추가 환경 변수가 필요하지 않습니다. Studio는 CDN의 자체 페이지를 제공하고 다른 모든 경로는 서버로 이동하므로 다음을 사용하여 추가하는 경로를 사용하세요.[`registerApiRoute()`](https://mastra.zisheng.pro/ko/docs/server/custom-api-routes) 은 각각의 경로에서 계속 접근할 수 있습니다. Studio에서 이미 사용하는 경로(예: `/agents` or `/workflows`), since Studio claims those first. > **경고:** Studio가 Mastra 서버에 연결되면 Agent, Workflow 및 Tool에 대한 전체 액세스 권한을 갖게 됩니다. 무단 액세스를 방지하려면 프로덕션 환경(예: 인증, VPN 등)에서 적절하게 보호해야 합니다. ## 선택적 재정의 Vercel 배포자는 Vercel 출력 API 기능 구성에 기록되는 구성 옵션을 지원합니다. 참조[`VercelDeployer` reference](https://mastra.zisheng.pro/ko/reference/deployer/vercel) for available options like `maxDuration`, `memory`, and `regions`. ## Observability 서버리스 함수는 응답 반환 후 즉시 종료될 수 있습니다. 원격 분석 전송과 같은 보류 중인 비동기 작업은 완료되기 전에 종료될 수 있습니다. 대기 중`flush()` 은 함수가 종료되기 전에 모든 Trace가 전송되도록 보장합니다. ```typescript import type { VercelRequest, VercelResponse } from '@vercel/node' import { mastra } from '../src/mastra' export default async function handler(req: VercelRequest, res: VercelResponse) { const { message } = req.body const agent = mastra.getAgent('myAgent') const result = await agent.generate([{ role: 'user', content: message }]) await mastra.observability.flush() return res.json(result) } ``` > **경고:** Vercel 배포자는 다음을 포함하지 않습니다.`flush` 호출에는 적용되지 않습니다. 이 기능이 필요하다면 응답을 반환하기 전에 해당 로직을 추가하도록 handler를 직접 래핑해야 합니다. 또는 다음과 같이 장시간 실행되는 서버에 배포합니다: [virtual machine](https://mastra.zisheng.pro/ko/guides/deployment/digital-ocean) where this isn't an issue. ## 관련된 - [VercelDeployer 참조](https://mastra.zisheng.pro/ko/reference/deployer/vercel) - [배포 개요](https://mastra.zisheng.pro/ko/docs/deployment/overview) - [서버 어댑터](https://mastra.zisheng.pro/ko/docs/server/server-adapters) - [웹 프레임워크 통합](https://mastra.zisheng.pro/ko/docs/deployment/web-framework)