You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
283 B

  1. export default function (req, res, next) {
  2. const redirects = [
  3. {
  4. from: '/',
  5. to: '/go'
  6. }
  7. ]
  8. const redirect = redirects.find(r => r.from === req.url)
  9. if (redirect) {
  10. res.writeHead(301, { Location: redirect.to })
  11. res.end()
  12. } else {
  13. next()
  14. }
  15. }