Coder Social home page Coder Social logo

renewerner87 / cloudflare-pages-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from charca/cloudflare-pages-auth

0.0 0.0 0.0 567 KB

Basic Authentication for Cloudflare Pages

License: MIT License

JavaScript 8.51% TypeScript 44.95% HTML 11.41% Svelte 35.13%

cloudflare-pages-auth's Introduction

cloudflare-pages-auth

Static site that is password-protected when deployed to Cloudflare Pages. This is a SvelteKit project, but the password-protection works independently of the framework you use.

Screenshot

๐Ÿš€ Getting Started

If you want to password-protect your own Cloudflare Pages site, you'll need to:

  1. Copy the contents of the functions directory from this repo into your own project.
  2. Add a CFP_PASSWORD environment variable to your Cloudflare Pages dashboard with the password you want to use.

The next time you deploy your site, it will be password-protected! ๐ŸŽ‰

๐Ÿ›  Running Locally

Since this is a SvelteKit project, first run the build command to generate the static site:

npm run build

Then, you'll need to use the wrangler CLI to run the site (with functions) locally:

npx wrangler pages dev build -b CFP_PASSWORD=test

Notice that you'll need to pass the CFP_PASSWORD environment variable when running the CLI command. If you don't pass it, the site will not be password-protected.

๐Ÿ’… Customization

  • The functions/template.ts file contains the HTML template of the login page. You can customize it to your liking.
  • The functions/constants.ts contains some other things you can customize, like the expiration of the auth cookie, or the list of paths that don't require authentication.

cloudflare-pages-auth's People

Contributors

charca avatar renewerner87 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.