Using Vercel config, I built a simple redirect system for domains and subdomains pointing at myles.garden. It also supports basic filesystem access for AtProto DID Verification.
Here’s the setup for stream.myles.garden:
import type { VercelConfig } from "@vercel/config/v1";
export const config: VercelConfig = {
outputDirectory: "public",
routes: [
// First it will route to any file in the ./public/ directory.
{ handle: "filesystem" },
// Next it will check if the client is requesting the root
// and if so, will redirect to myles.garden/stream with some
// utm query parameters for tracking.
{
src: "/",
status: 302,
headers: {
Location:
"https://myles.garden/stream?utm_source=stream.myles.garden&utm_medium=redirect",
},
},
// Finally it’ll just redirect everything and include the utm
// parameters.
{
src: "/(.*)",
status: 302,
headers: {
Location:
"https://myles.garden/stream/$1?utm_source=stream.myles.garden&utm_medium=redirect",
},
},
],
};