Recipes

Troubleshooting

Common problems and how to fix them.

This page lists problems that site developers meet with Tenon, from the first start to production. Each entry names the symptom, its cause and the fix. Search the page for the error message you see.

Setup

Creating the first admin answers 403

Cause: the database already has a user. Only the first user can sign up. Often an old cms.db is still there, or an older dev server still runs on the same port and answers instead. Astro 7 runs astro dev in the background.

Fix:

  • Stop the old server. For Astro, run npx astro dev stop.
  • Sign in with the user that exists. If nobody knows the password, run npx tenon users recover <email>. It prints a link that signs the user in once. See tenon users.
  • In development, point the database at a new file to start over.

/_tenon answers 404 in TanStack Start

Cause: the route file is named _tenon.$.ts. TanStack Router treats a file that starts with _ as a layout without a path, so it never matches /_tenon.

Fix: name the file src/routes/[_]tenon.$.ts. The brackets escape the _. See TanStack Start.

Saving alt text fails with answered 200 without JSON

Renaming a file or changing its alt text fails. The client's error reads like PATCH /media/<id> answered 200 without JSON.

Cause: the route that hands /_tenon/* to the CMS skips some request methods. For those, your app answers with one of its own pages, and the client rejects any answer that is not JSON. Older TanStack Start starters list only GET, POST, PUT and DELETE, without PATCH.

Fix: hand every method to the CMS. In TanStack Start:

src/routes/[_]tenon.$.ts
const handle = ({ request }: { request: Request }) => cms.fetch(request);

export const Route = createFileRoute("/_tenon/$")({
  server: { handlers: { ANY: handle } },
});

A new admin path does not apply

Cause: the adapters read admin.path from tenon.config.ts when they start, and write the value of an env var it reads into the build.

Fix: restart the dev server, or build again. In TanStack Start, also rename the admin route file to the new path, like src/routes/cms.$.ts.

Build and deploy

nuxt preview or astro preview loses the data or the secret

Cause:

  • nuxt preview runs from .output/. A relative file:./cms.db or ./.uploads then lands in the build output, and the next build deletes it.
  • astro preview does not load .env, so TENON_SECRET is missing.

Fix: use absolute paths for the database and the uploads folder in Nuxt. In Astro, load .env yourself, as the start script of the Node starter does:

node --env-file-if-exists=.env ./dist/server/entry.mjs

The server cannot find @libsql/<platform>

Cause: libSQL ships one native binary per operating system and CPU. The project was installed or built on another platform than the server, for example on macOS for a Linux container.

Fix: install and build on the platform you deploy to, for example inside the Docker image or in CI. Turso by URL (libsql://…) needs no binary.

A prerendered page fails the build on Cloudflare

Cause: the CMS lives in a Durable Object, and no object exists at build time.

Fix: set output: "server" in astro.config.ts, so pages that read the CMS render per request. See Cloudflare.

wrangler deploy fails with inherit binding 'MEDIA' is invalid

The full message is inherit binding 'MEDIA' is invalid: previous version does not have binding named 'MEDIA'.

Cause: R2 is not enabled on the Cloudflare account, so Wrangler cannot create the bucket.

Fix: enable R2 in the Cloudflare dashboard, then deploy again. npx wrangler r2 bucket list answers with code 10042 until R2 is on.

The deploy on Vercel fails because of a cron job

Cause: the Vercel Hobby plan allows one cron job a day. In TanStack Start and standalone projects, the job clock becomes a Vercel Cron Job that runs every minute.

Fix: set tenonAdmin({ jobs: false }) and call the clock route from an outside cron service, or use the Pro plan. The Vercel starters of npm create tenoncms set jobs: false. See Vercel.

Media

Uploads fail on Vercel, or the Media page is missing

Cause: serverless functions have a read-only disk, so the default storage on the local disk cannot keep files. Without a media option there is then no media library, and media: true throws.

Fix: store files in a bucket with s3(), or r2() with keys. See Media Storage.

Uploads fail with A part has no ETag

The full message is A part has no ETag. The bucket's CORS setting MUST expose the ETag header.

Cause: the browser uploads straight to the bucket. The bucket's CORS setting does not allow it, or hides the ETag header of each part.

Fix: allow PUT from the admin's origin and expose ETag in the bucket's CORS setting:

cors.json
[
  {
    "AllowedOrigins": ["https://example.com"],
    "AllowedMethods": ["PUT"],
    "AllowedHeaders": ["*"],
    "ExposeHeaders": ["ETag"]
  }
]

Large uploads fail with 413 behind a reverse proxy

Cause: with local() storage, every part of an upload is one request to your server, up to partSize (16 MB by default). The proxy's body limit is smaller. nginx allows 1 MB by default.

Fix: raise the limit above partSize, like client_max_body_size 20m; in nginx.

Images keep their old sizes

Cause: the stored image variants follow the options they were made with.

Fix: after a change to sizes, presets or the provider, run npx tenon media regenerate. See tenon media.

A deleted or replaced file still shows

Cause: files that Tenon serves carry Cache-Control: public, max-age=300, s-maxage=3600 when media has no read rule. A CDN keeps them for up to an hour.

Fix: wait, or purge the file in your CDN. With a read rule on media, files carry private, no-cache, so a CDN does not keep them.

Sign-in and email

Cause: links in emails and from tenon users recover use auth.baseURL, else site.url. In production, neither is set, or site.url names a site on another origin than the CMS.

Fix: set TENON_SITE_URL (NUXT_TENON_SITE_URL in Nuxt) to the public origin. When the CMS runs on its own origin, also set auth.baseURL. See The CMS origin.

Signing in to the admin fails with INVALID_ORIGIN

Cause: the CMS runs on another origin than the site, and only site.url is set. Sign-in then expects the site's origin.

Fix: set auth.baseURL to the origin of the CMS, without a path. See Set the origins.

Cause: both need email. Without an email adapter and without your own sender, they are off, and /_tenon/auth-status reports them as false. Tenon warns at startup when they are the only methods.

Fix: set up email. Until then, npx tenon users recover <email> prints a sign-in link.

Invites and sign-in emails do not arrive

Causes and fixes:

  • Cloudflare Email Service on the Workers Free plan sends only to verified destination addresses. Verify the address, or use the Workers Paid plan.
  • The sender's domain is not onboarded to Cloudflare Email Service. The send fails with a code like E_SENDER_NOT_VERIFIED. Onboard the domain in the Cloudflare dashboard.
  • wrangler dev only logs each mail of the send_email binding and saves it to a file. Add "remote": true to the binding to send real mail.
  • SMTP on Workers: port 25 is blocked. Use port 465, or 587 with STARTTLS.

See Cloudflare Email Service and SMTP.

Passkey sign-in fails on a preview deployment

Cause: a passkey works only on the host it was created on.

Fix: sign in with another method on preview hosts.

A site on another origin

Drafts and the admin bar do not show on the site

Cause: the site does not get the editor's cookies. The site and the CMS share no parent domain, crossSubDomainCookies has no domain, or the site runs on HTTP while the session cookie is Secure.

Fix: serve both from one parent domain over HTTPS, and set crossSubDomainCookies with domain. Pass the full admin URL to preview({ admin: "https://cms.example.com/admin" }). See Share the cookies.

The site's browser code gets a CORS error

Cause: CORS allows only the origin of site.url, with GET and POST, on the content and admin bar routes. The request comes from another origin, uses another method, or calls another route, like sign-in.

Fix: list more origins in cors.origin, and PUT or DELETE in cors.allowMethods. Sign-in, users, API keys and invites stay closed to other origins. See Allow more origins.

publish() or delete() answers 403 from the site's server

Cause: a write without a JSON body needs an Origin header for the CSRF check, and a server sends none. This covers publish(), delete() and media.upload() through createRequestClient().

Fix: use a client with an API key for those writes. See Write content.

Jobs and data

Scheduled publishing does nothing

Cause: nothing runs the jobs on this host:

  • Astro on Vercel and other serverless hosts have no clock.
  • Nuxt on Vercel has no clock either: Nitro 2 makes no Vercel Cron Job. The Nuxt module warns in a Vercel build.
  • jobs: false is set, and nothing calls the clock route.

Fix: set jobs.secret, and call the clock route every minute from a cron service.

A request hangs after adding a hook or a seed

It can also fail with TRANSACTION_ACTIVE.

Cause: a hook, seed or onInit calls the instance from tenon.config.ts instead of the cms it gets. A seed's call waits for the seed itself. On a database with one connection, like :memory: libSQL, PGlite or a Durable Object, a hook's call waits for the open transaction.

Fix: use the cms argument in every hook. To run jobs from a hook, queue them with cms.jobs.queue(). Never call cms.jobs.run() there.