nuxt-community / redirect-module

No more cumbersome redirects for Nuxt 2!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Either borken or I don't know how to use

SHxKM opened this issue · comments

commented

I'm honestly starting to think something is wrong with my Nuxt.js (2.8.1) setup. No matter how I set up the redirects, nothing is taking effect.

I've tried every single one of these in nuxt.config.js (some are taken from #19 for testing purposes):

{
    from: '^(.*)$',
    to: (from, req) => {
      let trailingUrl = req.url.endsWith('/') ? req.url : req.url + '/'
      return trailingUrl
    }
}
redirect: [
  {
    from: '^/someUrlHere/(.*)$',
    to: (from, req) => {
      const param = req.url.match(/functionAsync\/(.*)$/)[1]
      return `/posts/${param}`
    }
  }
]

I have tried both ways to include in config:

...
router: {
    mode: 'history',
    middleware: ['user-agent']
  },
  redirect: [
    {
      from: '^.*(?<!\/)$',
      to: (from, req) => req.url + '/'
    }
  ],
  build: {
....

or:

modules: [
    '@nuxtjs/pwa',
    ['@nuxtjs/redirect-module', {
      from: '^/about', to: '/'
    }],
    ['@nuxtjs/auth', {

But none works. What am I doing wrong?