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

Custom 404 Page #885

Closed
feychou opened this issue Mar 1, 2017 · 4 comments
Closed

Custom 404 Page #885

feychou opened this issue Mar 1, 2017 · 4 comments

Comments

@feychou
Copy link
Contributor

feychou commented Mar 1, 2017

Is there a way to easily customise the 404 response - for instance with a custom page?

I also tried to add my catch-all route in the route entry file and associate it with a not-found-page: however, this results in a 200. Is there a way to define the 404 status code in the page lifecycle?

@gigabo
Copy link
Contributor

gigabo commented Mar 1, 2017

Is there a way to define the 404 status code in the page lifecycle?

Yep, it's not well documented, but you should be able to do this by adding hasDocument to your response from handleRoute:

class NotFoundPage {
    handleRoute() {
        return {code: 404, hasDocument: true};
    }

    getElements() {
        return <Awesome404 />;
    }
}

@feychou
Copy link
Contributor Author

feychou commented Mar 1, 2017

@gigabo That works, thank you. I had figured how to return the code, however I was still missing the hasDocument option.

I could open a PR for documenting this somewhere in the docs (maybe where I would have expected to find it). Maybe one of the examples could also have a custom 404 page?

@gigabo
Copy link
Contributor

gigabo commented Mar 1, 2017

@feychou Yeah, that would be awesome!

@doug-wade
Copy link
Collaborator

This was fixed in #893; closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants