Skip to content

HTML error pages for HTML-wanting requests #3333

Open

Description

@david-crespo

When we 404 (or other error) in the browser we currently return JSON. This is a terrible mediocre user experience. In general, we should default to JSON responses because Nexus is primarily a JSON API. Fortunately, as you can see in the screenshot, when we get a request from a browser (or more concretely, a request to which we would prefer to respond with HTML) we can tell from the Accept header on the request.

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8

We could instead use the presence or lack of /v1 prefix on the path, since that's the implicit marker for API vs. Console requests, but I think the HTML header is better: we're just doing what they tell us to do. They say they want HTML, give them HTML.

What should the HTML be? The web console currently generates the assets served as console pages, including an index.html which is mostly a dummy container for a React app to run in. The console can easily generate other HTML pages (Vite docs on multiple entry points). This has the advantage of keeping the console responsible for all HTML and CSS, and we could reuse our existing styling.

image

Activity

  1. changed the title [-]Need HTML error pages for HTML requests[/-] [+]HTML error pages for HTML-wanting requests[/+] on Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions