Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add error metadata to index.html to forward backend errors #1907

Closed
Assignees
kylecarbs
Labels
apiArea: HTTP API
@kylecarbs

Description

@kylecarbs

When the browser accesses the API for authentication redirection or accessing apps, displaying a JSON error isn't useful! In these circumstances, we should serveindex.html with an injected error and status code to display.

VS Code does this in meta tags with{{WORKBENCH_WEB_CONFIGURATION}}:
https://github.com/microsoft/vscode/blob/8a8c175605bb3503dc4515700dfd8dcf68dac98b/src/vs/code/browser/workbench/workbench.html#L19-L20

To display a helpful error in the frontend, we should get the status code and response text:

<metaid="api-response"data-statuscode="{{API_STATUS_CODE}}"data-message="{{API_MESSAGE}}"/>

An example of this is accessing a web app, where it may be offline. This results in a 502 error right now, which isn't helpful to the user. We could send the following to the frontend instead:

<metaid="api-response"data-statuscode="404"data-message="code-server isn't running! Make sure it's active on 'localhost:3000'."/>

This is injected dynamically using a string replace by our static server in Go. The frontend could register on a per-path basis to displayreally friendly errors, but for now we could do a catch-all by making our 404 page check ifdata-statuscode is set. If so, we'll display the error!

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp