onedrive-cf-index is currently being refactored as
onedrive-vercel-index for better UX and simplified deployments. New issues and pull requests here will not be monitored and managed for now.
Live demo at Spencer's OneDrive Index.
README.mdif found in current folder. Rendered with github-markdown-css.
?proxied- Downloads the file through CloudFlare Workers if (1)
proxyDownloadis true in
config/default.jsand (2) parameter is present in url.
?raw- Return direct raw file instead of rich rendered preview if parameter is present.
?raw&proxiedare both valid.
Yes, this means you can use this project as an image storage service or for serving static files, for example:
You can limit access to folders (i.e., declaring private folders) by adding their paths to
src/auth/config.js. You can optionally enable this feature with the
AUTH_ENABLED toggle variable also inside that file, and you can specify the username in
NAME and the password using wrangler.
Note that the password is stored inside the
AUTH_PASSWORD Cloudflare Worker secret. You should never commit your password into a git repository, not even a private one. The
AUTH_PASSWORD secret can be added with wrangler:
wrangler secret put AUTH_PASSWORD # Type out your self-defined AUTH_PASSWORD here
Check out the following sections for details on using wrangler to set CloudFlare Worker secrets (which are also called environment variables).
See the new features section at the original onedrive-index-cloudflare-worker project page for reference, although I cannot guarantee that all features are usable.
Very, very long, tedious, step by step guide warning!
Namefor your blade app,
Supported account typesto
Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox). OneDrive
Azure AD -.
Redirect URI (optional)to
Web(the multiselect dropdown) and
Get your Application (client) ID -
Certificates & secrets panel, click
New client secret and create a new secret called
Add, and copy the
Value of the
client_secret (You only have this one chance to copy it.).
API permissions panel, select
Microsoft Graph, select
Delegated permissions, search for
offline_access, Files.Read, Files.Read.All, select all three of them and click
You should have these permissions ready:
refresh_token. On your local machine that has a working installation of Node.js and npm (See Preparations for recommendations for installing Node.js and its toolchain), execute the following command:
Select the options that you need, and enter the tokens that we just acquired from above. The names are self-explanatory.
redirect_url can be set to
http://localhost. For more information please go check out the repo at: beetcb/ms-graph-cli.
Finally, create a dedicated folder for your public files inside OneDrive, for instance:
/Public. Please don't share your root folder directly!
After all this hassle, you should have successfully acquired the following tokens and secrets:
base: Defaults to
_Yes, I know it's a long and tedious procedure, but it's Microsoft, we can understand. _
Fork then clone, or directly clone this repository. Install dependencies locally, you'll need Node.js,
We strongly recommend you install npm with a Node version manager like n or nvm, which will allow wrangler to install configuration data in a global node_modules directory in your user's home directory, without requiring that you run as root.
# Install cloudflare workers official packing and publishing tool npm i @cloudflare/wrangler -g # Install dependencies with npm npm install # Login to Cloudflare with wrangler wrangler login # Verify wrangler status with this command wrangler whoami
Login to your CloudFlare account at https://dash.cloudflare.com/login, select your domain, and scroll down a bit. You'll see your
zone_id there (on the right sidebar). Also create a DRAFT worker at
Manage Workers ->
Create a Worker with a cool name.
name: The draft worker's name, your worker will be published at
account_id: Your Cloudflare Account ID.
zone_id: Your Cloudflare Zone ID.
Create Cloudflare Workers KV bucket named
# Create KV bucket wrangler kv:namespace create "BUCKET" # ... or, create KV bucket with preview functions enabled wrangler kv:namespace create "BUCKET" --preview
Preview is used for local preview test only. It will not affect the image preview on page.
kv_namespaces: Your Cloudflare KV namespace, you should substitute the
preview_idvalues accordingly. If you don't need preview functions, you can remove the
basepath from above.
Add secrets to Cloudflare Workers environment variables with
AUTH_PASSWORD and private folders, refer to Private folders):
# Add your refresh_token and client_secret to Cloudflare wrangler secret put REFRESH_TOKEN # ... enter your refresh_token from above here wrangler secret put CLIENT_SECRET # ... enter your client_secret from above here wrangler secret put AUTH_PASSWORD # Type out your self-defined AUTH_PASSWORD here
You can preview the worker with
After making sure everything is ok, you can publish your worker with:
You can also create a GitHub Actions for auto publishing your worker on
push. See main.yml.
For custom domains, refer to How to Setup Cloudflare Workers on a Custom Domain.
introon the default landing page here: src/folderView.js. Write HTML directly.
onedrive-cf-index Spencer Woo. Released under the MIT License.
Authored and maintained by Spencer Woo.