decodeURI causes server error when uri malformed.
See original GitHub issueWhile causing an error itself is fine, but there should be some way to catch the error and possibly do a redirect rather then stopping the execution of the app (this mainly applies to malformed links to the app).
Having it throw an exception as it does is fine by default, but there should be some sort of event that can be used to force a redirect. Likely just from a try/catch on the decodeURI
function.
Like so (in nuxt.config.js
):
redirectError(url, error) {
return '/?err_info=' + error.code //could pass some info if possible
}
Though I would think it would be better to keep everything under “redirect” but that would likely lead to a breaking change.
Could add info for things like status code and all that in the return, handling even times when the url might be repairable, just not by decodeURI
.
This case mainly comes up from migrating to nuxt from a pre-established site where there might be bad url’s that need to be handled for a time. In the case here, there are 90k pages in the site migrated and this error has been triggered about once a day since launch, it is also seen in Google Search Console so google reads them as valid links on its end but can’t track down the locations of all the links easily. It would be easier to cache the error and redirect that way in my mind.
I plan to eventually do a pull request when I get time, it does not seem like it would be a terribly difficult update to do (and it would get sentry to stop yelling at me lol). Would this be a good way of handling this? Or would there be a better method?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
I’m working on this feature…
Should be able to find some time later this month @manniL and I will try to get a PR together then.