Skip to content

Repository files navigation

CC-switch R2 WebDAV

English | 简体中文

Cloudflare Worker WebDAV shim for CC-switch cloud sync. It is built as a companion for the open-source CC-switch tool, exposing the small WebDAV subset CC-switch needs and storing files in a private Cloudflare R2 bucket.

This is intentionally small. It is not a complete WebDAV server, and it does not try to cover general file management. The goal is to give CC-switch a stable sync endpoint backed by your own R2 storage.

Fit

Use this project if you want to:

  • Store CC-switch cloud sync data in your own R2 bucket.
  • Deploy a small Worker with no database and no always-on server.
  • Protect the sync endpoint with Basic Auth.
  • Support only the WebDAV methods CC-switch needs.

This project is not meant to be:

  • A general-purpose WebDAV file server.
  • A multi-user storage system.
  • A replacement for full file management tools.
  • A complete WebDAV compatibility layer for arbitrary clients.

Product Flow Sketch

Hand-drawn PRD sketch for CC-switch R2 WebDAV

Landing Page Preview

Desensitized hand-drawn landing page preview

What It Implements

  • OPTIONS for capability checks
  • PROPFIND for connection checks and path existence
  • MKCOL as a directory-compatible no-op
  • PUT to upload objects into R2
  • GET to download objects from R2, including range responses
  • HEAD for object metadata and ETag checks

It is not a full WebDAV server. It is intentionally scoped to CC-switch sync files.

Explicit Non-Goals

The following are intentionally not implemented:

  • DELETE
  • MOVE / COPY
  • LOCK / UNLOCK
  • Directory listing
  • Multi-user permissions
  • Quotas, sharing, versioning, or audit logs
  • Compatibility guarantees for every WebDAV client

Setup

  1. Create an R2 bucket, for example cc-switch-sync.
  2. Update wrangler.toml if your bucket name is different.
  3. Install dependencies:
pnpm install
  1. Configure Worker values for Basic Auth:
pnpm wrangler secret put DAV_LOGIN
pnpm wrangler secret put DAV_CODE

These two secrets are the Basic Auth credentials checked by the Worker:

  • DAV_LOGIN corresponds to the WebDAV account field in CC-switch.
  • DAV_CODE corresponds to the WebDAV password/code field in CC-switch.

For deployed usage, configure both values. If both are missing, the Worker treats Basic Auth as disabled.

  1. Deploy:
pnpm deploy

Your WebDAV endpoint uses the deployed Worker domain and the configured DAV_PREFIX.

Local Development

Create a local .dev.vars file with your own values:

DAV_LOGIN=<your-login>
DAV_CODE=<your-code>

Then run:

pnpm dev

Run type checks:

pnpm typecheck

CC-switch Settings

Use the deployed Worker URL as the WebDAV server URL:

WebDAV Server URL: https://<your-worker-domain>/dav/
WebDAV Account: <same value as DAV_LOGIN>
WebDAV Password: <same value as DAV_CODE>
Remote Directory: cc-switch-sync

The resulting R2 object keys will look like:

cc-switch-sync/current/db.sql
cc-switch-sync/current/skills.zip
cc-switch-sync/current/manifest.json

Configuration

Name Type Default Description
CC_SWITCH_BUCKET R2 binding Required R2 bucket used to store sync objects.
DAV_LOGIN Worker value Empty Basic Auth account name. Auth is disabled only when both DAV values are empty.
DAV_CODE Worker value Empty Basic Auth shared code.
WEBDAV_REALM Worker var CC Switch R2 WebDAV Basic Auth realm shown by clients.
DAV_PREFIX Worker var /dav URL path prefix used as the WebDAV root.

Safety Notes

  • Always configure DAV_LOGIN and DAV_CODE before deploying a public Worker.
  • Do not commit local deployment config.
  • Keep the R2 bucket private and access it through the Worker.
  • This project does not provide audit logging, rate limiting, tenant isolation, or abuse controls.
  • Use HTTPS Worker URLs only.

FAQ

Can I use this as a normal WebDAV drive?

Not recommended. It implements only the methods CC-switch needs for cloud sync.

Why does MKCOL not create directories in R2?

R2 is object storage, not a traditional filesystem. The Worker treats directory creation as a compatibility response so WebDAV clients can continue their sync flow.

Why is there a landing page?

The root path and WebDAV root return a small status page so you can confirm the Worker is running and identify the endpoint.

Why is the package still marked private?

The repository is intended to be open source, but the package is not configured for npm publishing. Keeping private: true prevents accidental publication.

License

MIT

About

Cloudflare Worker WebDAV shim for CC-switch cloud sync

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages