From 66e0e4889165b403c2923274f1df0b836533a4b5 Mon Sep 17 00:00:00 2001 From: tommytrg Date: Mon, 28 Oct 2024 10:55:26 +0100 Subject: [PATCH] feat: redirect specific routes to socials --- server/middleware/redirects.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server/middleware/redirects.ts diff --git a/server/middleware/redirects.ts b/server/middleware/redirects.ts new file mode 100644 index 00000000..7c1f9dc2 --- /dev/null +++ b/server/middleware/redirects.ts @@ -0,0 +1,24 @@ +export default defineEventHandler((event) => { + const { req, res } = event + + const redirects: Record = { + '/x': 'https://x.com/witnet_io', + '/twitter': 'https://x.com/witnet_io', + '/discord': 'http://discord.gg/witnet', + '/telegram': 'https://t.me/witnetio', + '/linkedin': 'https://www.linkedin.com/company/witnet/', + '/github': 'https://github.com/witnet', + '/docs': 'https://docs.witnet.io/', + '/medium': 'https://medium.com/witnet', + '/reddit': 'https://www.reddit.com/r/witnet/', + '/foundation': 'https://witnet.foundation/', + '/ethereum': 'https://feeds.witnet.io/ethereum', + } + + const redirectUrl = redirects[req.url as string] + + if (redirectUrl) { + res.writeHead(302, { Location: redirectUrl }) + res.end() + } +})