This repository contains a Cloudflare Worker script that supports configuring meet URLs using the DMS (Document Management System) as the source of truth. The worker acts as a dynamic redirector, mapping user-friendly meet URLs to their respective target URLs based on data fetched from the DMS.
MIE employees looking to set up a meet can follow the directions here.
meet.bluehive.com
meet.enterprise.health
meet.mieweb.org
meet.webch.art
meet.mieweb.com
The Cloudflare Worker script serves as a URL redirector that:
- Fetches a JSON mapping of usernames to meet URLs from the DMS.
- Redirects requests to the corresponding meet URL if the username exists.
- Returns a custom HTML page if the username is not found.
- Redirects to the main domain if accessed without a specific path.
-
Parsing the Request:
- The script extracts the path and hostname from the incoming request URL.
- The path (e.g.,
/username
) is used as the key to look up in the JSON data. - The hostname is used to determine if a subdomain exists.
-
Root URL Redirection:
- If the request path is empty (i.e.,
meet.domain.com
), the script checks for a subdomain. - If a subdomain exists, it removes it and redirects to the main domain (e.g.,
domain.com
).
- If the request path is empty (i.e.,
-
Fetching JSON Data:
- The script fetches JSON data from the DMS URL:
https://mie.webchartnow.com/webchart.cgi?f=layoutnouser&&name=conferencelist&raw=1&json
- This data contains mappings of usernames to their respective meet URLs.
- The script fetches JSON data from the DMS URL:
-
Redirecting to the Meet URL:
- If the username exists in the JSON data, the script performs a 302 redirect to the associated meet URL.
-
Handling Username Not Found:
- If the username is not found, the script returns a custom HTML page informing the user.
- The HTML includes a message and a link to set up a new meet URL.
- Network Errors: If fetching the JSON data fails, the script returns a 500 Internal Server Error.
- JSON Parsing Errors: If the fetched data cannot be parsed as JSON, a 500 error is returned.
- Unhandled Exceptions: Any unexpected errors result in a 500 Internal Server Error response.
The main logic resides within the fetch
event handler of the Cloudflare Worker:
export default {
async fetch(request, env, ctx) {
// Main logic here
},
};
- Caching:
- Cloudflare Workers Documentation: