원하는 패키지 매니저로 프로젝트에 SDK를 추가하세요.
npm install aws-cdkyarn add aws-cdkpnpm add aws-cdk최소한의 설정으로 시작하고 실행하세요.
// Lambda@Edge functionexports.handler = async (event) => { const request = event.Records[0].cf.request if (request.uri.startsWith('/tracio/')) { request.origin = { custom: { domainName: 'edge.tracio.ai', protocol: 'https', } } } return request}오류 처리, 로딩 상태, 고급 구성을 갖춘 프로덕션 준비 패턴.
// Lambda@Edge — origin-request functionexports.handler = async (event) => { const request = event.Records[0].cf.request if (!request.uri.startsWith('/tracio/')) { return request } // Rewrite the origin to your tracio.ai server request.uri = request.uri.replace(/^\/tracio/, '') request.origin = { custom: { domainName: process.env.TRACIO_ORIGIN || 'edge.tracio.ai', port: 443, protocol: 'https', sslProtocols: ['TLSv1.2'], path: '', readTimeout: 10, keepaliveTimeout: 5, }, } // Forward client IP for accurate geolocation request.headers['x-forwarded-for'] = [{ key: 'X-Forwarded-For', value: request.clientIp, }] // Set cache behavior: cache agent script, skip identification if (request.uri.includes('/agent')) { request.headers['cache-control'] = [{ key: 'Cache-Control', value: 'public, max-age=3600', }] } return request}SDK를 초기화하고 구성하기 위한 모든 옵션.
publicKeystring대시보드에서 발급받은 공개 키 — 브라우저에 실어 보내도 안전합니다endpointstring프록시 라우팅 배포를 위한 사용자 지정 엔드포인트 URL — 명시적 URL이 region보다 우선합니다regionstring데이터 리전: us 또는 eutimeoutMsnumbergetResult() 호출 전체에 대한 타임아웃(밀리초)linkedIdstring로그인한 사용자의 내부 계정 ID — 같은 디바이스를 공유하는 방문을 연결할 수 있습니다tagstring식별 요청에 붙이는 자유 형식 라벨 (예: checkout 또는 login)debugboolean스크립트 수명 주기와 네트워크 활동을 브라우저 콘솔에 기록합니다scriptUrlstring에이전트 스크립트 URL 전체 재정의 — 셀프 호스팅 또는 Subresource Integrity용전체 API 레퍼런스, 웹훅 구성, 고급 가이드로 더 깊이 알아보세요.