Deliver public assets through CDN for Next.js · Ample Computer

Deliver public assets through CDN for Next.js

Deliver public assets for a Next.js app through the Ample CDN. Publish a bucket with ample bucket publish, upload versioned assets with long-lived Cache-Control headers, and reference the bucket's public URL (public_url from ample bucket publish, https://./) from your pages. The CDN serves bucket objects; the app's own responses are still served by the app.

What it runs on

You need

Exact tested configuration

build
npm run build --if-present

install
npm install

runtime
node

sizes
1vcpu-1gb

start
npm run start

template
node-22

Steps

  1. Publish the bucket. Publishing makes objects readable at the CDN URL; keep private data in a separate, unpublished bucket.
   $ ample bucket publish <bucket-name>
  1. Upload versioned assets. Use keys such as assets//file and set Cache-Control: public, max-age=31536000, immutable; change the version to invalidate.

  2. Reference the CDN URL. Pass S3_PUBLIC_URL to the app and build asset URLs from it.

   $ ample deploy . --name <app-name> --public --env S3_PUBLIC_URL=... --env S3_ENDPOINT=... --env S3_REGION=... --env S3_BUCKET=... --env S3_ACCESS_KEY_ID=... --env S3_SECRET_ACCESS_KEY=...
  1. Verify delivery. Fetch /api/asset-url for the asset URL, then fetch that URL: the CDN must return the asset.

  2. Verify. Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.

   $ ample logs <deployment_id> --kind build

How it was checked

✓ asset URL resolves through the CDN · http get /api/asset-url → “/assets/”

Evidence

  1. November 6, 2026 · canary run Next.js route handler uploaded a versioned asset to a published bucket and returned its CDN URL; the CDN served the asset publicly.

  2. November 5, 2026 · canary run ample bucket create issued credentials; PutObject and GetObject succeeded through the public S3 endpoint; publish exposed the object at its public URL with an ETag; unpublish and delete cleaned up.

Tested examples

What it doesn’t cover