Skip to main content

Cloudflare Deployment Guide · v0.1.0

Deploy Re Player to Cloudflare

Re Player (RP) is alink-based media library: admins register external video, audio and image links as virtual /root directories, and visitors browse the tree and play media directly in the browser. It runs on Astro 7 + Cloudflare Workers and needs no server of your own. This guide takes you from zero to a running instance: create the Cloudflare app → bind a D1 database → set environment variables → sign in to the admin panel.

Node ≥ 22 Astro 7 Cloudflare Workers D1 database MIT open source

This page only explains how to deploy it yourself; there is no online deployment service, and we do not deploy it on your behalf.

01Overview

Re Player is alink-based media library: it does not mount any storage service itself. Instead it registers external media links as virtual directories, and the player on the visitor side loads them on demand. Every page and API is server-rendered by Astro on Cloudflare Workers, and data is written to Cloudflare D1.

Cloudflare runtimeWorkers
Build toolAstro 7
Data storeCloudflare D1
LicenseMIT

Multi-format playback

Video, audio and images play with one click, all handled by the web player.

Link pseudo-mount

Mount any external media link under a fixed /root path to form a directory tree.

ASS subtitles

Rendered in the browser by JASSUB / libass, with built-in Chinese and Japanese font fallbacks.

LRC lyrics

Real-time sync with auto-scrolling highlight; bilingual lyrics and dual-line timestamps supported.

Automatic language

Picks Chinese / English / Japanese from the visitor IP, with manual override.

Visitor analytics

View visits, directories, media and playback events /table in the admin panel.

Five themes

Default, Retro, Azure, New Blue and Light Gray — switch with one click on public pages.

Password protection

/admin Both the admin panel and the /table analytics page require the admin password.

D1 persistence

Falls back to in-memory storage when D1 is not bound, so you can get it running first and add the database later.

Repository The English, Simplified Chinese and Japanese docs live in README.md, README.zh-CN.md, README.ja.md. This page only covers deployment; see the README for feature details.

02Choosing a deployment method

The Re Player app itself runs on Cloudflare Workers ; the only difference is how you get the code to Cloudflare.

MethodEffortHow it publishesBest for
Cloudflare Workers · Git integration Recommended Connect a GitHub repo; push or click to build and publish automatically People who set it up once and then only touch the repo
Cloudflare Workers · Wrangler CLI Advanced Build and upload locally with a single command Terminal users who want full control over publishing
Run locally (preview only) Optional npm run local / Local.cmd Try it on your own computer; reachable only from this machine

Two things to keep straight Re Player uses the @astrojs/cloudflare adapter (output: "server"), so the build output is a Workers runtime (dist/server/entry.mjs plus dist/server/wrangler.json, including the ASSETS and DB bindings) — not a pile of static files, so it can only be deployed to Cloudflare Workers; it cannot be handed to Pages as a static site. This guide itself is a plain static page: it only explains how to deploy Re Player, offers no online deployment service, and we do not deploy it for you.

Requirements

  • Node.js ≥ 22 (required by Astro 7) and npm;
  • A Cloudflare account (the free plan is enough — Workers and D1 both include free quota);
  • The Git integration also needs a GitHub account (fork the repo to your own account);
  • The CLI route needs no extra global tools — npx wrangler uses the dependencies already inside the project.

03Prerequisites

  1. Create a Cloudflare account

    Open dash.cloudflare.com to sign up and log in. The free plan already includes usable Workers and D1 quota, which is plenty for personal use.

  2. Install Node.js ≥ 22

    Download the installer from nodejs.org and confirm the version in your terminal afterwards. Anything below 22 makes the Astro 7 build fail.

  3. Get the code

    Clone the repository, or download and unzip the ZIP from Releases. For the Git integration, fork the repo to your own account first.

  4. (Optional) Log in to Wrangler

    Needed only for the CLI publishing route. The first run opens an authorization page in your browser — just approve it.

 Terminal
# 1. Check the environment
node -v      # v22 or newer is required
npm -v

# 2. Get the source code
git clone https://github.com/lircia/RP-Re_Player.git
cd RP-Re_Player
npm install

# 3. Log in to Cloudflare (CLI publishing only)
npx wrangler login

Tip The whole process only needs npm — no Docker and no extra global toolchain.

04Deploy to Cloudflare Workers

This is the most hands-off route: connect the repo to Cloudflare and every push builds and publishes automatically, with historical versions kept for instant rollback.

  1. Fork the repository

    Open github.com/lircia/RP-Re_Player, and click “Fork” in the top-right corner to fork it to your own account, so you can customise the config and push changes later.

  2. Create a Workers application in Cloudflare

    In the dashboard sidebar pick “Compute & AI” → “Workers & Pages” → “Create application” → choose “Workers”→ “Import an existing Git repository / Connect to Git”. On first use, authorise Cloudflare to access GitHub when prompted.

  3. Pick the repository and production branch

    Select the repo you forked; leave the production branch at the default main.

  4. Check the build and deploy settings

    Keep the build command at the default npm run build; the deploy command must point explicitly at the config file generated by the adapter (see the table below). The first build takes about 1–3 minutes.

  5. Save and deploy

    When it finishes you get a <project-name>.workers.dev address. You can also bind a custom domain under “Settings → Domains & Routes”.

  6. Redeploy after binding D1

    A database binding only affects later deployments, so finish section 06 first, then click “Retry deployment” once.

SettingValueNotes
Root directory/The repository root is the project root
Build commandnpm run buildLeave the default; internally it is astro check && astro build
Deploy commandnpx wrangler deploy --config dist/server/wrangler.jsonPoints at the Worker config in the adapter output (with the ASSETS and DB bindings)
Node versionNODE_VERSION = 22Add it under “Settings → Variables and Secrets” so the build environment does not use an old Node

Why the deploy command is not the default npm run build produces dist/server/entry.mjs and dist/server/wrangler.json; Wrangler reads wrangler.toml in the project root by default, while the config that really describes the Worker entry point and the static-asset binding is generated by the adapter — hence the need to add --config dist/server/wrangler.json.

05CLI deployment and local preview

5.1 Publish locally with the Wrangler CLI

Clone the repo locally and one command builds and publishes it — a good fit for terminal users who want full control over the release.

 Terminal
git clone https://github.com/lircia/RP-Re_Player.git
cd RP-Re_Player
npm install

# Build and publish to Cloudflare Workers
npm run cf:deploy

# equivalent to:
# npm run build && wrangler deploy --config dist/server/wrangler.json

Common commands npm run cf:dev starts a dev server with the Workers runtime on your machine; npm run preview previews an existing build.

5.2 Run locally (optional)

To see it on your own machine first, run npm run local (on Windows you can simply double-click Local.cmd ). By default it serves HTTP on 127.0.0.1 on 80 and HTTPS 443 , and the address shows as soers.de5.net, with masteradmin as the default admin password.

Note The local-run capability in the main repository is not complete: it is reachable only from the machine running the service. If you need access from other devices on your LAN, use the release package and follow the instructions inside it.

06Create and bind the D1 database

D1 stores pseudo-mount information, visitor analytics and settings. RP runs without it too (it falls back to in-memory storage), but data is lost on restart or redeploy, so bind it for real use.

  1. Create the D1 database

    In the dashboard pick “Storage & Databases” → “D1 SQL database” → “Create database”, name it re-play (any name works); you can also create it from the CLI.

  2. Copy the database_id

    Open the database detail page and copy the database ID.

  3. Write it into the project config

    Put the ID into wrangler.toml and commit it to your repository. With the Git integration you can also add the D1 binding under “Settings → Bindings” in the dashboard. The binding name must stay DB.

  4. Redeploy

    Bindings only take effect at deploy time, so redeploy once (with the Git integration, click “Retry deployment”).

  5. Verify

    Visit /admin or /table — RP creates the tables it needs and starts writing.

 wrangler.toml
name = "rp"
compatibility_date = "2026-09-06"
keep_vars = true

[[d1_databases]]
binding = "DB"              # must be DB — do not rename it
database_name = "re-play"      # your D1 database name
database_id = "your D1 database ID"
 Terminal · manage the database from the CLI
# create the database (the output prints a database_id to put in wrangler.toml)
npx wrangler d1 create re-play

# list existing databases
npx wrangler d1 list

# back up the database (recommended before updating)
npx wrangler d1 export re-play --remote --output backup.sql

Tables RP creates automatically

TablePurpose
rp_pseudo_linksPseudo-mount (virtual directory) data
rp_media_visitorsMedia playback progress and completion stats
rp_visitor_eventsVisit, directory, media and playback events
rp_settingsStored environment variables
rp_visitor_themeVisitor theme for public pages

The binding name must be DB Rename it and RP cannot find the database; it silently falls back to in-memory storage, which shows up as “all data gone after a restart”.

No manual table creation RP creates and upgrades these tables on startup; you never paste SQL into the D1 console.

07Environment variables

Add them under “Settings → Variables and Secrets” in the Workers project, or declare them in the wrangler.toml file, in the [vars] section. Every variable becomes effective only after a redeploy.

VariablePurpose
AExternal media shown before the visitor page opens
BA and C maximum display or playback time in seconds, default 4.2
C and A optional external audio played alongside; once set, A mutes the video
NSite name
PAdmin password (save it as a Secret)
USUmami script URL
UIUmami website ID
UHOptional: Umami host URL
UDOptional: Umami domain list

DB is a binding, not a variable DB is a binding: configure it as described in section 06 rather than adding it to the variable list.

 wrangler.toml · [vars]
[vars]
A  = ""                              # external media shown before the visitor page opens
B  = "4.2"                           # maximum display or playback time for A / C, in seconds
C  = ""                              # optional external audio played alongside A
N  = "Re Player"                     # site name
P  = "masteradmin"                   # admin password — always change it in production
US = "https://cloud.umami.is/script.js"
UI = ""
UH = ""
UD = ""

Variable precedence

  • keep_vars = true stops Wrangler from deleting variables you configured in the dashboard, so the dashboard and wrangler.toml can coexist;
  • When D1 is available, RP writes an rp_settings key into env: for every non-empty short variable that is bound (only when the key does not exist yet); from then on RP reads the value from the database first;
  • in other words, a value edited in the admin panel is not overwritten by a redeploy; conversely, if you change a value in the environment variables and nothing happens, rp_settings already holds the old value.

Change the password The default password masteradmin is public knowledge, and both the /admin and /table rely on it for protection; save it as a Secret rather than committing it in plain text to a public repository.

08First visit and the admin panel

  1. Open the site

    Visit https://<project-name>.workers.dev (or your custom domain). You see the intro animation first; on mobile it forwards to /Local.

  2. Sign in to the admin panel

    Open /admin and sign in with the password set by the P variable (default masteradmin).

  3. Mount media

    Register external video / audio / image links as virtual directories and files in the admin panel; the site name, theme and more are set here too.

  4. Check analytics

    Visit /table to see visits, directories, media and playback events.

RouteDescription
/Intro animation; on mobile it forwards to /Local
/ReIntro animation page (external intro media, then enters /Loading)
/LoadingPick a language, then continue to the visitor page
/LocalRegular visitor media library
/Local/Pash/...Regular pseudo-mount display URL
/Tree/.../root/tree native player page for the mounted media
/tableVisitor analytics page (admin password required)
/adminAdmin panel (pseudo-mounts, themes, settings)

Tree and Local Tree and Local sit at the same level, but Tree does not appear in the regular Local listing. If you want it in the directory tree, register the folder as /tree.

09Updating

  1. Back up the database first

    The data in D1 is the one thing that cannot be regenerated, so exporting it before an upgrade is the safest move.

  2. Pull the latest code

    With the CLI use git pull; with the Git integration, push your code or simply redeploy.

  3. Update dependencies and republish

    Run npm install , then rebuild and deploy.

  4. Schema upgrades are automatic

    RP creates and upgrades the tables on startup, so no manual SQL is needed.

 Terminal · update and republish
# 1. Back up the database
npx wrangler d1 export re-play --remote --output backup.sql

# 2. Pull the latest code and update dependencies
git pull
npm install

# 3. Rebuild and publish
npm run cf:deploy

Rollback is easy With the Git integration every deployment is recorded, so if something breaks you can pick a previous version on the “Deployments” page and roll back in one click; RP upgrades the schema compatibly, so manual work is rarely needed.

10FAQ

The build fails saying the Node version is too old — what now?

Astro 7 requires Node.js ≥ 22. Upgrade Node to 22 or newer locally; in the Cloudflare build environment, add NODE_VERSION = 22 under the project’s “Settings → Variables and Secrets”, then redeploy.

Can Re Player be deployed to Cloudflare Pages as a static site?

No. The adapter outputs the Workers runtime entry dist/server/entry.mjs and dist/server/wrangler.json (which contains the ASSETS static-asset binding and the DB binding), and that needs a server runtime, not a pile of static files. Deploy the application itself to Cloudflare Workers.

The page will not open after deploying, or it hangs on the intro animation?

First check the deploy log for errors, then make sure the database binding and variables are configured. The entry page loads the external media referenced by A / C , so if those URLs are unreachable the animation can wait a long time; clear both variables once to narrow it down.

Can the D1 binding name be something else?

No, it must stay DB. If you rename it, RP cannot read the database and falls back to in-memory storage, which shows up as “everything gone after a restart or redeploy”.

I have not set up D1 yet — can I still get it running?

Yes. Without D1, RP falls back to in-memory storage: everything works, but data is lost after a restart, a redeploy or an instance switch. Trying it first and adding the database later works fine.

I changed an environment variable and nothing happened?

Two possibilities. One: environment variables only take effect after a redeploy; two: when D1 is available, the rp_settings key stored in env: takes precedence, so a value edited in the admin panel overrides the environment variable. Check this against the precedence notes in section 07.

/admin will not open, or the password is always rejected?

Make sure the P variable is saved and that you redeployed; if you reused an older database, check whether rp_settings still holds an old env:P. You can store the password as a Secret; changing it also requires a redeploy.

Media fails to play, or subtitles / lyrics will not load?

The media, the .ass subtitles and the .lrc lyrics all have to be public HTTP(S) URLs that Cloudflare Workers can reach. RP fetches subtitles and lyrics through its own endpoint to work around browser CORS limits, but if the origin rejects the request outright (hotlink protection, authentication, IP limits) it still fails.

Want other devices on your LAN to reach the local service?

The local-run capability in the main repository is not complete and is reachable only from the machine running the service; if you need access from other devices on your LAN, use the release package and follow the instructions inside it.

What does the whole site roughly cost?

Cloudflare Workers and D1 both have free tiers, and personal use or small-audience sharing normally stays well within them; only with heavy traffic do you need to watch Workers request counts and D1 reads and writes.

11Appendix

11.1 Project structure

 RP-Re_Player
RP-Re_Player
├── src/                        # source code
│   ├── layouts/                # page layouts
│   ├── lib/                    # business logic (pseudo-mounts, subtitles, lyrics, themes …)
│   ├── pages/                  # route pages
│   │   ├── api/                # API endpoints
│   │   │   ├── admin/          # admin API
│   │   │   └── public/         # public visitor API
│   │   ├── Local/              # visitor media library
│   │   └── tree/               # native player
│   ├── styles/                 # global and theme styles
│   └── types/                  # type definitions
├── public/                     # static assets (fonts, icons, posters)
├── scripts/                    # build and local-run scripts
├── astro.config.mjs            # Astro configuration
├── wrangler.toml               # Cloudflare configuration
├── package.json                # project dependencies
└── LICENSE                     # MIT license

11.2 Links

License Re Player is open source under the MIT license: you are free to use, modify and redistribute it. See the LICENSE file in the repository for the full terms.

About this page This page only documents deployment: we do not deploy for you and there is no online deployment service. It is hand-written HTML / CSS / JS with no third-party framework and no external requests, so you may mirror or self-host it as a whole.