nuxt-security: Customization on error response

How to properly handle response? I created an ~error.vue and it works for other error responses like 404 response but not on 429.

Version

nuxt-security: ^0.9.0 nuxt: 3.0.0

Reproduction Link

What is Expected?

I was expecting to customize the error response like redirecting to another page or customize the default response.

What is actually happening?

I am getting the default error response from nuxt Screenshot 2022-12-16 at 2 45 58 AM

Thank you

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

@ReaganM02

You are in the right place 😉

Are you using the correct branch? It should be feat/optional-throw-error

I cannot pass the method as it is removed from the config in the middleware. Instead, I will add an optional property called throwError. By default it has a value of true and will throw an error once certain condition is met (for example 429 after too many requests from rate limiter). But when set to false, it will return an object with the error but will not throw an error. Thanks to this approach you will be able to take this object and do whatever you want with it. For example show a custom error. I will create a pull request with this functionality for you to check out.