Home
Softono
b

betahuhn

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by betahuhn

cf-worker-redirect
Open Source

cf-worker-redirect

<div align="center"> # β˜οΈπŸ”— URL redirection using CF Workers [![Node CI](https://github.com/BetaHuhn/cf-worker-redirect/workflows/Node%20CI/badge.svg)](https://github.com/BetaHuhn/cf-worker-redirect/actions?query=workflow%3A%22Node+CI%22) [![Release CI](https://github.com/BetaHuhn/cf-worker-redirect/workflows/Release%20CI/badge.svg)](https://github.com/BetaHuhn/cf-worker-redirect/actions?query=workflow%3A%22Release+CI%22) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/BetaHuhn/cf-worker-redirect/blob/master/LICENSE) ![David](https://img.shields.io/david/betahuhn/cf-worker-redirect) URL redirection running at the edge with Cloudflare Workers and Worker KV. </div> ## ⭐ Features - **Extremely fast** - *Runs on Cloudflare's Edge* - **Simple to integrate** - *Integrate it with existing sites using Cloudflare* - **Easy to manage** - *Redirects are stored in Workers KV* - **Supports URL parameters** - *URL parameters are appended to the target URL if not already present* - **Works in front of an existing website** - *If no redirect is found it can pass the request to the origin* ## πŸš€ Get started If you want to deploy this Worker yourself, clone this repo and cd into it: ```shell git clone https://github.com/betahuhn/cf-worker-redirect && cd cf-worker-redirect ``` Install the required dev dependencies: ```shell npm install ``` Next start the interactive deployment process with [worker-setup](https://github.com/BetaHuhn/worker-setup): ```shell npm run deploy ``` You will be asked to login to Cloudflare if not already authenticated. The programm will guide you through the process of setting up and deploying the Worker under your own Cloudflare Account. ## πŸ“š Usage After you have deployed your Worker, head over to the [KV section of the Workers Dashboard](https://dash.cloudflare.com/?to=/:account/workers/kv/namespaces) and select your Namespace. To add a redirect, simply enter the URL path you want to redirect as the key (including the leading `/`) and the target URL as the value. Example: | Key | Value | | ------------- | ------------- | | `/github` | `https://github.com/BetaHuhn` | If your your Worker runs on example.com, all requests to example.com/github will be redirected to https://github.com/BetaHuhn. If you have multiple domains pointing to the same worker, you can specify the domain in front of the path to target it specifically. Example: | Key | Value | | ------------- | ------------- | | `example.com/github` | `https://github.com/BetaHuhn` | | `example2.com/github` | `https://github.com/` | | `/foo` | `https://example3.com/bar` | Both example.com/foo and example2.com/foo will redirect to example3.com/bar ### Root page Since a key in your KV Namespace specifies a URL path with or without the domain, you can also specify a redirect if a user requests the root of your page (i.e. example.com/): | Key | Value | | ------------- | ------------- | | `/` | `https://example.com/home` | | `example.com/` | `https://example.com/home` | ### 404 Page By default if a path is not found in the KV Namespace a 404 error will be returned. You can optionally redirect all 404 errors to a custom URL by specifying it with the `404` key: | Key | Value | | ------------- | ------------- | | `404` | `https://example.com/home` | | `example.com/404` | `https://example.com/home` | ### In front of origin If you use the worker in front of your actual website, you can tell the worker to pass requests to the origin if no redirect is found: | Key | Value | | ------------- | ------------- | | `404` | `pass` | You can also use the `pass` value on any other key: | Key | Value | | ------------- | ------------- | | `example.com/home` | `pass` | ### URL parameters All URL search parameters will be passed on to the final URL if they are not already present in the specified target URL. Example with a Worker running at example.com: | Key | Value | | ------------- | ------------- | | `/blog-post-test` | `https://example.com/blog/posts/test` | A user requesting example.com/blog-post-test?ref=Twitter will be redirected to https://example.com/blog/posts/test?ref=Twitter. > If the specified target URL would have been `https://example.com/blog/posts/test?ref=Campaign` then the parameter `ref=Twitter` would have been ignored ## πŸ”¨ Manual Setup If you want to reuse the code for this Worker, generate a new one with [`wrangler`](https://github.com/cloudflare/wrangler): ```shell wrangler generate new-worker https://github.com/betahuhn/cf-worker-redirect && cd new-worker ``` Next generate the `wrangler.toml` from the given template: ```shell npm run generate ``` Set your account id in `wrangler.toml`, which can be found on your [Workers Dashboard](https://dash.cloudflare.com/?to=/:account/workers). Create a KV namespace for cf-worker-redirect: ```shell wrangler kv:namespace create "REDIRECT_KV" ``` You will be instructed to append some content to the `wrangler.toml` file. Publish your Worker with: `wrangler publish` [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/BetaHuhn/cf-worker-redirect) ## πŸ’» Available commands - run `yarn lint` or `npm run lint` to run eslint. - run `yarn test` or `npm run test` to run all Mocha tests. - run `yarn dev` or `npm run dev` to run the Worker locally with [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/commands#dev). - run `yarn build` or `npm run build` to produce a production version with webpack. ## ❔ About This project was developed by me ([@betahuhn](https://github.com/BetaHuhn)) in my free time. If you want to support me: [![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=394RTSBEEEFEE) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F81S2RK) ## πŸ“„ License Copyright 2021 Maximilian Schiller This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Link Shortening & Tracking
38 Github Stars
qrgen
Open Source

qrgen

# qrgen.cc - QR-Code generator/url-shortener [![Server](https://github.com/BetaHuhn/qrgen/workflows/Server/badge.svg)](https://github.com/BetaHuhn/qrgen/actions?query=workflow%3AServer) [![Client](https://github.com/BetaHuhn/qrgen/workflows/Client/badge.svg)](https://github.com/BetaHuhn/qrgen/actions?query=workflow%3AClient) [![Coverage Status](https://coveralls.io/repos/github/BetaHuhn/qrgen/badge.svg)](https://coveralls.io/github/BetaHuhn/qrgen) QrGen.cc is a free service that lets you create QR-Codes and shortened URLs from any link quickly and easily ![gif](qrgen.gif) ## Live Website The live version of this project can be found here: https://qrgen.cc ## Introduction This repo contains the source code for the [qrgen.cc](https://qrgen.cc) QR-Code generator/url-shortener. Just add qrgen.cc/ infront of a url and get a QR-Code aswell as a short url. Alternatively you can visit [qrgen.cc](https://qrgen.cc) and create them manually. The website is build with a Node.js/Express backend and a vue.js frontend. The built vue.js files are hosted by the express server. ## Note There is also a Chrome/Firefox extension available. It lets you create a QR-Code/short URL by simply pressing the icon in your browser, or even with a keyboard shortcut. More info [here](https://github.com/BetaHuhn/qrgen-extension) ## Installation Download the repo: ``` git clone https://github.com/BetaHuhn/qrgen ``` Change directory: ``` cd qrgen ``` Create .env file: ``` nano .env ``` Add: ``` DB_CONNECTION_STRING=Your MongoDB connection string; defaults to mongodb://localhost:27017/qrgen PORT=Port the server runs on; defaults to 3000 ``` Install dependencies: ``` npm run dependencies ``` Build backend and frontend: ``` npm run build ``` Start app: ``` npm run start ``` ## Authors * **Maximilian Schiller** ([@BetaHuhn](https://github.com/BetaHuhn)) - *Main contributor* * **Alexander Janke** ([@alexanderjanke](https://github.com/alexanderjanke)) - *Conversion to Typescript* ## License This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

Link Shortening & Tracking
21 Github Stars