From 0e658dbdfdd4e6ece53ee04caf93d596034be587 Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 20 Mar 2025 14:50:15 -0700 Subject: blink: redirect on root route (#8029) * make root route redirect to 301 * use config * end * add a comment --- bskylink/src/routes/index.ts | 2 ++ bskylink/src/routes/root.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 bskylink/src/routes/root.ts (limited to 'bskylink') diff --git a/bskylink/src/routes/index.ts b/bskylink/src/routes/index.ts index cfdaf3eaa..9fd20d276 100644 --- a/bskylink/src/routes/index.ts +++ b/bskylink/src/routes/index.ts @@ -4,6 +4,7 @@ import {AppContext} from '../context.js' import {default as createShortLink} from './createShortLink.js' import {default as health} from './health.js' import {default as redirect} from './redirect.js' +import {default as root} from './root.js' import {default as shortLink} from './shortLink.js' import {default as siteAssociation} from './siteAssociation.js' @@ -14,6 +15,7 @@ export default function (ctx: AppContext, app: Express) { app = siteAssociation(ctx, app) // GET /.well-known/apple-app-site-association app = redirect(ctx, app) // GET /redirect app = createShortLink(ctx, app) // POST /link + app = root(ctx, app) // GET / (redirect to bsky.app on root) app = shortLink(ctx, app) // GET /:linkId (should go last due to permissive matching) return app } diff --git a/bskylink/src/routes/root.ts b/bskylink/src/routes/root.ts new file mode 100644 index 000000000..12bdf1515 --- /dev/null +++ b/bskylink/src/routes/root.ts @@ -0,0 +1,14 @@ +import {Express} from 'express' + +import {AppContext} from '../context.js' +import {handler} from './util.js' + +export default function (ctx: AppContext, app: Express) { + return app.get( + '/', + handler(async (_req, res) => { + res.setHeader('Location', `https://${ctx.cfg.service.appHostname}`) + return res.status(301).end() + }), + ) +} -- cgit 1.4.1