Skip to Content
TutorialsAdvanced Topics2. Deploying to Production

2. Deploying to Production

Your app is working locally. This tutorial walks through going live: the deployment pipeline Buildpad sets up for you, the first push to main, DaaS CORS, and a repeatable workflow that ships each change through a pull request.

This tutorial puts your app live from its main branch, which uses the project’s one environment. To give your users a separate, always-on environment that changes only when a second person approves, see Production.

By the end you’ll have:

  • Your app live on AWS Amplify, built and deployed each time main changes
  • No CORS setup: a Buildpad Engine project needs none DaaS CORS configured for the app’s address
  • A repeatable workflow: a branch, a pull request, a merge
  • An optional custom domain

Prerequisites

  • A working Buildpad app (either tutorial series completed)
  • Node.js v24 and pnpm v10+ installed locally

How the Pipeline Works

Buildpad sets up the deployment pipeline when your project is created. By the time you downloaded the starter kit, the following were in place:

WhatDetail
Git repositoryCreated and managed by Buildpad. It stays empty until your first push. The starter’s .git/ already has the remote origin and its credentials.
Initial branchtemporary-local, the starter’s only local branch.
AWS Amplify appConnected to the repository and watching main. No console setup is needed.
Amplify build specamplify.yml in the starter. It installs pnpm 10.33.2 with npm install -g, runs pnpm install, then runs pnpm build.
Environment variablesSet on the Amplify app by Buildpad: the Engine URL, the public anon key and the tenant id,the Supabase URL and keys and the DaaS URL, and NEXT_PUBLIC_HOST_ORIGIN, the app’s public address. The same data-service values are in the starter’s .env.local for local work.
App addresshttps://main.<app id>.amplifyapp.com, in .env.local as NEXT_PUBLIC_MICROAPP_URL_MAIN and on the project’s Details page.

What deploys: a change to main. Amplify builds and deploys it by itself.

You don’t need an AWS account, a GitHub account, or access to any console. The platform manages the git repository, the Amplify app, the project backend (the Buildpad Engine) (Supabase and DaaS) and the app’s settings.

Know What Goes Where

The data service’s settings are in .env.local for local work, and already set on the Amplify app by Buildpad for its builds. Never commit .env.local to git.

On a Buildpad Engine project, .env.local points both URLs at the Engine URL and has no service role key:

# .env.local — Buildpad Engine project, written by Buildpad, never committed to git NEXT_PUBLIC_SUPABASE_URL=<Engine URL> NEXT_PUBLIC_BUILDPAD_DAAS_URL=<Engine URL> NEXT_PUBLIC_SUPABASE_ANON_KEY=buildpad-engine-public-anon-key NEXT_PUBLIC_BUILDPAD_TENANT_ID=<project tenant id> NEXT_PUBLIC_MICROAPP_URL_MAIN=https://main.d1234abcde.amplifyapp.com

The anon key of a Buildpad Engine project is a fixed value, not a secret. See The Starter Kit.

# .env.local — written by Buildpad, never committed to git NEXT_PUBLIC_SUPABASE_URL=https://...db.buildpad.ai NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... SUPABASE_SERVICE_ROLE_KEY=eyJ... NEXT_PUBLIC_BUILDPAD_DAAS_URL=https://...daas.buildpad.ai NEXT_PUBLIC_MICROAPP_URL_MAIN=https://main.d1234abcde.amplifyapp.com

On the project’s Details page, a project Admin sees these under Environment variables, marked Platform and read-only. See Deployment and environment variables.

Configure DaaS CORS

On a Buildpad Engine project, skip this step. The Engine’s data API accepts any origin and never uses cookies, so there is nothing to configure. Do not add credentials: 'include' to your calls.

On a Supabase project, your DaaS backend rejects requests from unknown origins. Add your Amplify URL using the mcp_daas_cors-settings MCP tool:

{ "action": "update", "cors_origins": [ "http://localhost:3000", "http://localhost:3001", "https://main.d1234abcde.amplifyapp.com" ], "cors_allow_credentials": true, "cors_max_age": 0 }

cors_allow_credentials: true is required. Every DaaS call uses credentials: 'include'. If this is false, browsers block all responses — lists show empty, forms silently fail to save.

cors_max_age: 0 forces browsers to recheck the preflight immediately after this change instead of serving a cached (stale) result.

Never use cors_origins: ["*"] when credentials: 'include' is in use. Browsers block wildcard CORS responses for credentialed requests — every single DaaS call will fail.

Check the Build Locally

Before anything reaches main, build and test the app on your computer:

git branch # temporary-local git remote -v # origin is the project's repository pnpm install && pnpm build && pnpm test

A build that fails locally fails on Amplify too. A failed deploy leaves the previous build live, but nothing new reaches the app until main builds again.

Make the First Deploy

The repository is empty until you push, so the first deploy creates main from your local branch:

git add . git commit -m "feat: first version of the app" git push origin temporary-local:main

Amplify starts building as soon as main exists. Follow it on the project’s Details page, where the Deployment card says Deploying and then Live, or on the Builds page for the logs. The first build takes a few minutes.

Then switch to main locally, so later branches start from it:

git fetch origin git checkout -b main --track origin/main

Verify End-to-End

Open the app’s address (on the Details page, on the App Hosting & Deployment card) and test the full flow:

  • App loads at the Amplify URL
  • Sign-in succeeds
  • Protected pages redirect unauthenticated users correctly
  • Data loads from the Engine from DaaS (collection lists show real records)
  • Create, edit, delete operations work
  • Sign out redirects correctly

Debugging:

SymptomLikely causeFix
Build failedThe app does not buildOpen the build’s log on the Builds page, run pnpm build locally, fix the errors and push again
A variable you set has no effectNEXT_PUBLIC_* values are written in at build timeClick Redeploy on the Details page
Sign-in redirects to localhost or the wrong addressThe app builds redirects from the request instead of its public addressUse NEXT_PUBLIC_HOST_ORIGIN (the CLI’s lib/origin.ts does)
Lists empty, forms silentDaaS CORS misconfigured (Supabase projects)Check cors_allow_credentials: true in the CORS step
A microapp link points at localhostconfig/app-urls.ts has a localhost fallbackPut the real Amplify URL in it and push

Set Up a Custom Domain (Optional)

A project Admin gives the app an address under apps.buildpad.ai, such as https://events.apps.buildpad.ai, without leaving the platform:

  1. Open the project’s Builds page (for a microapp, the microapp’s Builds tab).
  2. On the Custom domains card, click Add domain, type a name such as events, and click Add domain.
  3. Wait until the domain shows Active, usually 5 to 15 minutes. The platform sets up the certificate and DNS; there is nothing to do at a DNS provider.

The domain serves the app’s main branch, and the .amplifyapp.com URL keeps working. Adding a domain does not change the app’s settings. If the app should use the new address as its public address (for sign-in redirects, for example), set NEXT_PUBLIC_HOST_ORIGIN to it and redeploy: ask your AI agent to do it with amplify_set_env_vars and amplify_redeploy, since the Details page shows that variable read-only. Then add the domain wherever you used the .amplifyapp.com URL:

  1. DaaS CORS origins (the CORS step, with both URLs; Supabase projects only)
  2. The fallbacks in config/app-urls.ts, if your app has microapps (commit and push)

For a domain of your own, such as app.example.com, contact Buildpad support. See Custom domains.

Amplify’s ~30 Second Request Limit

Every API route in your app runs as a Lambda function that Amplify Hosting manages. Two things follow from that, confirmed by hitting both in practice:

  • A hard ceiling around 30 seconds. Amplify’s SSR layer notices a slow, buffered response and returns a clean 504 around 28s; if it doesn’t catch it first, the Lambda’s own hard timeout fires at 30s with a raw 500.
  • Responses are buffered, not streamed, by default. Unless a Lambda is on a streaming invoke mode (not something Amplify Hosting exposes), nothing reaches the browser until the function returns. A ReadableStream response from your own API route doesn’t actually stream to the client in production — it silently accumulates inside the Lambda and hits the same ~30s wall, just failing differently (a raw 500 instead of a graceful 504).

This only shows up after deploying. next dev streams and runs long requests fine — Node’s local dev server has no Lambda or timeout in the path. Test anything slow or streaming on the actual Amplify URL, not just locally, before calling it done.

There’s no configurable timeout to raise here. If a feature’s work can genuinely take longer than ~30s, or needs to stream a response as it’s generated, don’t build it as a single request/response call:

  • Client-driven chunking — for a task whose length isn’t known upfront (e.g. calling a slow third-party API), have the client repeatedly call your API route in a loop within a time budget per call, each round trip comfortably under 30s, until the work reports done. Good when you don’t want to stand up background infrastructure for an otherwise simple feature.
  • A worker — for anything that should keep running independently of a browser tab, retry on failure, or run on a schedule. See Workers — it’s a long-lived process outside Amplify’s Lambda constraints entirely, reached by publishing a job and polling (or subscribing to) its result via DaaS.

Deployment Checklist

Before sharing the app’s address:

  • The app builds locally with pnpm build
  • The Deployment card on the Details page says Live
  • The full flow works on the deployed address
  • DaaS CORS includes the Amplify URL with cors_allow_credentials: true (Supabase projects only)
  • config/app-urls.ts, if your app has one, has real addresses, not localhost
  • No secrets in git: git log --all -- .env* | head returns nothing

Shipping Each Change

After the first deploy, ship each change through a pull request, so that someone sees it before it deploys:

# 1. Start a branch from the latest main git checkout main && git pull git checkout -b feature/my-change # 2. Develop and check locally pnpm dev pnpm install && pnpm build && pnpm test # 3. Commit and push the branch git add . git commit -m "feat: describe your change" git push origin feature/my-change

Then:

  1. Open the project’s Code page and click New pull request. Choose the repository and your branch, give it a title, and click Submit pull request. Your AI agent can open it for you with pr_create.
  2. A project Admin reviews it and clicks Merge & deploy. Amplify builds and deploys main.

To make every change go through a pull request, a project Admin turns on Block direct pushes to main under Code → Settings. See Code and Pull Requests.

main is the project’s Development environment. If your users need an environment that changes only when a second person approves, set up Production and promote what you tested.

What’s Next

  • Monitoring — The project’s Builds page shows the build history and the build logs. The project’s Monitoring page shows the health, uptime and errors of your deployed app. See Monitoring.
  • Production — Give your users an always-on environment that changes only through an approved Promotion. See Production.
  • Workflow automation — Tutorial 5: Workflow Automation covers validation and notifications useful in production
  • Custom domain — add an address under apps.buildpad.ai from the Custom domains card on the Builds page; see Set Up a Custom Domain
Last updated on