1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How can I change the response status from a component to the server (SSR) in Angular v19

Discussão em 'Angular' iniciado por Bachir31, Março 25, 2025.

  1. Bachir31

    Bachir31 Guest

    I am working on an Angular v19 project with SSR enabled for better SEO. I have two components:

    • A detail component that displays the details of an entity.
    • A 404-page-not-found component that is shown when the entity does not exist.

    If the entity does not exist, I want to redirect the user to the 404 page and return a 404 HTTP status instead of 200.

    Currently, when I make a curl request to the URL of a non-existing entity, I receive the correct 404 page content, but the HTTP status remains 200 instead of 404.

    Is there a way to modify the HTTP status code to 404 from inside my 404-page-not-found component when running Angular with SSR? If not, what would be the correct approach to achieve this behavior?

    Any help would be appreciated!

    Continue reading...

Compartilhe esta Página