Cloudflare Pages Deployment
All three Muse & Co portals are hosted on Cloudflare Pages. This guide covers how to deploy each one, run database migrations, and manage secrets.
Portal Deployment Commands
Customer Portal (ncmuse.co)
cd muse-customer
npm run deployThe deploy script in package.json handles the build and Wrangler deploy in one step.
Admin Portal (staff.ncmuse.co)
cd muse-admin
npm run build
npx wrangler pages deploy dist --project-name=muse-adminINFO
The admin portal uses a two-step process: build first, then deploy the dist/ directory. Make sure the build completes successfully before running the deploy command.
Wiki (wiki.ncmuse.co)
cd muse-wiki
npm run build
npx wrangler pages deploy docs/.vitepress/dist --project-name=muse-wikiWARNING
Note the different output directory for VitePress. The wiki build output is at docs/.vitepress/dist, not dist/. Deploying the wrong directory will result in a broken site.
Deployment Summary
| Portal | Project Name | Build Command | Deploy Directory |
|---|---|---|---|
| Customer | muse-customer | npm run deploy (all-in-one) | dist/ |
| Admin | muse-admin | npm run build | dist/ |
| Wiki | muse-wiki | npm run build | docs/.vitepress/dist |
Database Migrations
Database migrations are SQL files stored in the migrations/ directory. They modify the D1 database schema (create tables, add columns, etc.).
Running a Migration
npx wrangler d1 execute muse-and-co-db --remote --file=migrations/XXXX_migration_name.sqlWARNING
Always use the --remote flag when running migrations against the production database. Without it, the migration only runs against your local D1 copy and production will not be updated.
Checking Migration Status
To see what tables exist in production:
npx wrangler d1 execute muse-and-co-db --remote --command="SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"Migration Best Practices
- Name migration files with a sequential number prefix:
0001_create_users.sql,0002_add_events_table.sql - Always test migrations locally first (without
--remote) - Migrations should be idempotent when possible (use
CREATE TABLE IF NOT EXISTS,ALTER TABLE ... ADD COLUMN IF NOT EXISTS) - Never modify a migration file that has already been run in production -- create a new migration instead
Managing Secrets
Secrets (API keys, credentials, signing keys) are set per-project and are not stored in code.
Setting a Secret
npx wrangler secret put SECRET_NAMEYou will be prompted to enter the value. The secret is encrypted and stored by Cloudflare.
Secrets via Dashboard
Alternatively, set secrets in the Cloudflare dashboard:
- Go to dash.cloudflare.com
- Select the Pages project
- Go to Settings > Environment Variables
- Add or update the variable
Required Secrets by Portal
| Secret | Customer | Admin | Notes |
|---|---|---|---|
STRIPE_SECRET_KEY | Yes | Yes | Stripe API key |
STRIPE_WEBHOOK_SECRET | Yes | -- | Stripe webhook signing secret |
AWS_SES_ACCESS_KEY | Yes | -- | AWS SES credentials for email |
AWS_SES_SECRET_KEY | Yes | -- | AWS SES credentials for email |
SESSION_SECRET | Yes | Yes | Cookie signing key |
TIP
When rotating a secret, update it in all projects that use it. Use npx wrangler secret put SECRET_NAME in each project directory.
Custom Domains
Custom domains (ncmuse.co, staff.ncmuse.co, wiki.ncmuse.co) are configured in the Cloudflare dashboard under each Pages project's Custom domains tab. DNS records are managed in the Cloudflare DNS dashboard.
If a custom domain stops working:
- Check the Pages project's Custom domains tab for any errors
- Verify the DNS record points to the Pages project (should be a CNAME)
- Check that the SSL/TLS certificate is active
Deployment Checklist
Before deploying any portal to production:
- [ ] Code builds successfully locally (
npm run build) - [ ] TypeScript has no errors (
npx tsc --noEmit) - [ ] Tested locally with
npx wrangler pages dev - [ ] Any new database migrations have been run with
--remote - [ ] Any new secrets have been set via
npx wrangler secret put - [ ] Verified the correct deploy directory (
dist/ordocs/.vitepress/dist)
Rollback
If a deployment causes issues, you can roll back to a previous deployment in the Cloudflare dashboard:
- Go to the Pages project
- Find the previous successful deployment in the deployment list
- Click on it and select Rollback to this deployment
This instantly reverts the live site to the selected deployment without needing to rebuild or redeploy.
Last updated: March 2026
