nuxt-community / redirect-module

No more cumbersome redirects for Nuxt 2!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to redirect to another route onDecodeError

MooseSaeed opened this issue · comments

I'm having an issue where I'm getting a lot of URI Malformed errors on Sentry from routes that are valid but has %2 at the end of it. So I need a way to remove the %2 whenever there is an error while decoding and redirect the user to that route.

How can I redirect the user to a different route onDecodeError?

Got that sorted out

			if (/^.*(%2)$/.test(req.url)) {
				res.setHeader('Location', encodeURI(req.url.slice(0, -2)))
				res.statusCode = 302
				res.end()
			} else {
				next(error)
			}