Skip to content

Getting Started

lyc8503 edited this page Oct 18, 2023 · 7 revisions

Prerequisites

  • a GitHub account
  • a Cloudflare account (free plan is enough for this usage)
  • 15 minutes of time
  • [Optional] a domain if you want to use custom domain (via CNAME)

Steps

  1. Fork this repo to your own account. (Maybe btw give it a star before forking? :3)

    fork

    You can leave all the options as default, change the repo name if you want.

    options
  2. Edit config/site.config.js and modify the options to your need.

    Basically if you're Onedrive international user with admin privilege, All you need to change is userPrincipalName and baseDirectory for this to work.

    But you may go through config/site.config.js to see if you want to customize your page.

    If you're using 世纪互联 or not having admin privilege on your organization, please refer to docs for more info.

    More docs: https://github.com/lyc8503/onedrive-cf-index-ng/wiki/Configurations

  3. Login into your cloudflare, navigate to Workers & Pages - Overview and create a new application.

    cloudflare

    Choose Pages and click on Connect to Git button.

    pages

    Connect your GitHub account to Cloudflare via OAuth and grant permissions on your forked repo. Choose your forked repo to continue.

    git

    Choose Next.js framework preset and leave other options as default, click on Save and Deploy.

    git

    Wait for the building process to finish, should finish in ~2min. Then click on Continue to project.

    git

    Now visiting the domain provided by Cloudflare (xxx.pages.dev) should return something like Error: Could not access built-in Node.js modules. Please make sure that your Cloudflare Pages project has the 'nodejs_compat' compatibility flag set.

    So let's continue to do that.

  4. Change settings and bind KV storage

    Navigate to Settings - Functions - Compatibility flags, set nodejs_compat for Production compatibility flags

    func compatibility

    At last, you also need to bind a KV storage.

    Navigate to Workers & Pages - KV, create a KV storage and choose whatever name you like.

    kv

    Get back to your pages config (Workers & Pages - Overview - <YOUR_PROJ_NAME> - Settings - Functions)

    func

    Bind the created KV storage with Variable name set to ONEDRIVE_CF_INDEX_KV.

    bind

    Now all config is done! Trigger a redeployment manually via Cloudflare dashboard as below or via modifying a random file in your GitHub repo to pick up the new config.

    bind
  5. Now visit the <YOUR_PROJ_NAME>-xxx.pages.dev domain and you will see the guide to setup your account.

    bind

    If you have finished the setup wizard but again get redirected to Step 1, it may be caused by cache or Cloudflare KV's latency, please try manually revisiting https://<YOUR_PROJ_NAME>-xxx.pages.dev 1~2 minutes later.

Clone this wiki locally