Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 not being caught by onPreResponse function #1094

Closed
jstrimpel opened this issue Oct 3, 2013 · 5 comments
Closed

404 not being caught by onPreResponse function #1094

jstrimpel opened this issue Oct 3, 2013 · 5 comments
Assignees
Labels
non issue Issue is not a problem or requires changes
Milestone

Comments

@jstrimpel
Copy link

I am seeing the 404 JSON response returned to the browser, but the status code (response._code) in the onPreResponse function below is 200. Additionally, response.isBoom is undefined. I am running version 1.13.0. Based on the documentation I would expect this to catch 404's. It is catching 500's. Is there something I am missing?

this.server.ext('onPreResponse', function (request, next) {
    var response = request.response();
    // if server render fails then send up HTML view, else return JSON error object
    if (response.isBoom) {
        if (request.raw.req.headers['x-requested-with'] !== 'XMLHttpRequest') {
            return next(request.generateView(response.response.code, response.response.payload));
        }
    }

    return next();
});
@jstrimpel
Copy link
Author

I updated to 1.14.0 and I am still experiencing the same issue as previously described.

@hueniverse hueniverse reopened this Oct 25, 2013
@hueniverse
Copy link
Contributor

The referenced commit had the wrong issue in the message. Should have been #1098.

hueniverse pushed a commit that referenced this issue Oct 25, 2013
@ghost ghost assigned hueniverse Oct 25, 2013
@hueniverse
Copy link
Contributor

I can't reproduce it. See commit above with new test added.

@kmdeepthi-zz
Copy link

I am facing the exact same issue and I have 1.14. Is the issue fixed?

@hueniverse
Copy link
Contributor

The test in cf418cb confirms this working correctly. If you can reproduce the issue in 1.17 please open a new issue.

jmonster pushed a commit to jmonster/hapi that referenced this issue Feb 10, 2014
jmonster pushed a commit to jmonster/hapi that referenced this issue Feb 10, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

3 participants