Giter Club home page Giter Club logo

firecdn's Introduction


๐Ÿ”ฅ F I R E C D N



What's that?

Firecdn is a low latancy cdn using firebase, You can directly upload a file (Authenticated) and share it on internet. It will be pretty much handy and very fast because you can choose your server's location.

Deploy

1. Setup Firebase

Setup the Firebase is simple. But firebase storage comes without access-control-allow-origin header (CORS) that's why we have to setup the cors.

  • Open Firebase Console
  • Create a New Project (Click on Add Project)
  • Give a Name, and setup the project
  • We have set write on storage only from the authenticated request, that's why we have to setup Firebase Auth. So, click on Authentication in Dashboard and hit Get Started
  • Enable Email/Password method in Sign-in providers
  • Click on users and add an user by entering Email & Password
  • Copy User UID of that created user
  • Now in Project's Dashboard click on Storage, Click on Get Started
  • Click on Next for security rules (Will change it later)
  • For cloud storage location, Setup your nearest location (Check this out) and hit Next
  • Copy the bucket url for later (starts with gs://)
  • Click on Rules and replace it with (Don't forget to add the Copied UID) ๐Ÿ‘‡
rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth.uid == "copied_uid";
    }
  }
}
  • Now everything is ready to go, Now have to setup the cors. For that got to shell.cloud.google.com (Same Account which is used in Firebase)
  • Paste the script in terminal ๐Ÿ‘‡
curl -sSL https://raw.githubusercontent.com/Pranay5463/firecdn/main/setcors.sh | bash
  • It will ask for bucket-url (Previously Copied), Paste that and hit enter and you are ready to go

2. Setup Website

  • Firstly fork this Repo (Also give a Star ๐Ÿ˜)
  • Open Firebase again, go to that created project and click add an web app
  • Give any name to it
  • It will give you some configuration scripts, Only copy this part like below
var firebaseConfig = {
    apiKey: "AIzaSyB9eBs10atrgeGAI-WQm6UO72lhzmT-vpo",
    authDomain: "thefirecdn.firebaseapp.com",
    projectId: "thefirecdn",
    storageBucket: "thefirecdn.appspot.com",
    messagingSenderId: "707022422419",
    appId: "1:707022422419:web:b51d29ade5652390246866"
  };
  • Edit firebase_config.js
  • Replace with the copied script in marked place
  • Now you can host the website using Vercel / Netlify / Github Pages etc.

Connect :

Credits :

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.