PUZZLTHINK

DEV NOTE

Moving the site

In ten days the hosting moved once and the database moved once.

PUZZLTHINK is built and run by one person. It started on the lowest-effort stack: Next.js on Vercel, with Supabase Cloud’s free plan for the database, sign-in and realtime.

This note records how that stack changed as more people came, using the commits and the numbers in their messages.

Published · 2026-11-26

19 November: fewer CDN requests

The first warning was the number of CDN requests. A commit on the evening of 19 November cut Vercel CDN requests three ways: links stopped prefetching every visible page in the background, icons and the manifest got a long browser cache (they had max-age=0), and Vercel’s two analytics tools were removed (Google Analytics already covered traffic).

20 November: onto Cloudflare Workers

The next afternoon the site moved to Cloudflare Workers using vinext, which keeps the Next.js app-router code as it is, builds it with Vite and runs it on Workers. Static assets are prerendered and served as Workers static assets; only other requests reach the Worker. The site settled on www.puzzlthink.com (the bare domain redirects), with the workers.dev address kept for direct checks.

The commits record the problems too: the Next.js Google Analytics component rendered undefined under vinext and made every page fail, so the GA tag is now added by hand. Two hours later every push to main deployed to Cloudflare automatically, and public client settings moved into a committed `.env.production` so CI builds match local ones.

21 November, 4:10 pm

The next limit was the database. At 16:10 on 21 November the free Supabase Cloud project saturated, at about 174 concurrent users according to the commit. Most API calls failed with 504, and requests were cut on the spot: home rankings and the Hall of Fame from a 60-second cache, the online heartbeat every 120 s, the home open-room list every 60 s.

The real fix was committed at 7:19 pm the same day: the database, sign-in, realtime and the Slitherlink finish check moved to Supabase on a self-run server, with the data copied over and served at api.puzzlthink.com. The commit says to merge it only at the planned cutover, right after the final data copy.

Why everyone signed in once more

The new server signs sign-in tokens with a different secret, so it could not verify sessions issued by the cloud. Left alone, browsers would keep sending tokens that every request rejects. So the browser’s sign-in storage key was renamed and the old keys removed: everyone signs in once more, and accounts and records stay as they were.

There was one more server job on 24 November, 10:00–10:30. From 9:56, just before, a black band under the header scrolled a maintenance notice (built to hide itself after 10:40), and it came down at 10:19 when the work was done.

Numbers every five minutes

Since the evening of 20 November the database keeps a snapshot every five minutes of users online, today’s visits and today’s plays (kept 180 days). Up to 2026-11-26, 14:00 KST, the highest concurrency recorded was 193 users at 14:10 on 26 November. The busiest day for plays was 25 November with 14,823.

Deploy-time 404s stuck in the cache

Fixed on the night of 25 November. Files under `/_next/static/` carry a content hash in their names, so they are cached for a year as immutable. But 404 responses for missing files went out with the same one-year cache.

Someone opening a page right as a deploy switched over could get a 404 — an old page asking for a new file, or a new page asking for one not uploaded yet — and that 404 stayed in their browser for a year. For them, even reloading showed "this page couldn’t load".

So every page now has a small script in its head. When a static file fails to load, it collects the address, refetches it past the cache (`cache: 'reload'`), and if that works, reloads the page once. Each file is tried only once per session, so it never reloads in a loop.

Where it stands

  • Web: Next.js (app router, Korean and English with next-intl) built with vinext and served from Cloudflare Workers, deployed automatically from main.
  • Data: a self-run Supabase (Postgres, sign-in, realtime). Records, rankings, icons and contests run as database functions and scheduled jobs.
  • Game logic: almost all in the browser — the AIs, and friend-room games (on the host’s browser) — so the server only keeps records and lists. The heavy Very Hard searches run in Web Workers.

Where this comes from

This note is written only from the code, the commit history and the aggregate numbers below.

  • `cloudflare.config.ts`, `vite.config.ts`, `src/app/[locale]/layout.tsx` (STATIC_HEAL)
  • Commits 1eb6cfe (11/19 fewer CDN requests), d46c657 (11/20 Cloudflare Workers and vinext, GA fix), f7e53aa (11/20 automatic deploys), a3651c4 (11/20 five-minute snapshots), d2dd35e (11/21 the 16:10 response), c1d1732 (11/21 self-run Supabase, signing in again), ecdb72d and 4046042 (11/24 maintenance band), d9bdc7d (11/25 static 404 self-heal)
  • DB aggregates (2026-11-26 14:22 KST): highest online count in online_snapshots and its time, game_plays_daily totals by day
  • Where the server is, how it is set up, its secrets and how it is reached are deliberately left out.

Read next

All dev notes →