Skip to content

Commit

Permalink
feat: redirect specific routes to socials
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommytrg committed Oct 28, 2024
1 parent 0c17ad1 commit 66e0e48
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/middleware/redirects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default defineEventHandler((event) => {
const { req, res } = event

const redirects: Record<string, string> = {
'/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()
}
})

0 comments on commit 66e0e48

Please sign in to comment.