Skip to content

Commit 5582498

Browse files
authored
chore: 404 Requests to workspace proxy direct back to the primary (#7353)
* chore: 404 Requests to workspace proxy direct back to the primary * Remove unnecessary sprintf
1 parent 04f9ca8 commit 5582498

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

enterprise/wsproxy/wsproxy.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"strings"
1111
"time"
1212

13-
"github.com/coder/coder/coderd/httpapi"
14-
1513
"github.com/go-chi/chi/v5"
1614
"github.com/google/uuid"
1715
"github.com/prometheus/client_golang/prometheus"
@@ -20,12 +18,14 @@ import (
2018

2119
"cdr.dev/slog"
2220
"github.com/coder/coder/buildinfo"
21+
"github.com/coder/coder/coderd/httpapi"
2322
"github.com/coder/coder/coderd/httpmw"
2423
"github.com/coder/coder/coderd/tracing"
2524
"github.com/coder/coder/coderd/workspaceapps"
2625
"github.com/coder/coder/coderd/wsconncache"
2726
"github.com/coder/coder/codersdk"
2827
"github.com/coder/coder/enterprise/wsproxy/wsproxysdk"
28+
"github.com/coder/coder/site"
2929
)
3030

3131
type Options struct {
@@ -233,6 +233,15 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
233233
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("OK")) })
234234
// TODO: @emyrk should this be authenticated or debounced?
235235
r.Get("/healthz-report", s.healthReport)
236+
r.NotFound(func(rw http.ResponseWriter, r *http.Request) {
237+
site.RenderStaticErrorPage(rw, r, site.ErrorPageData{
238+
Status: 404,
239+
Title: "Route Not Found",
240+
Description: "The route you requested does not exist on this workspace proxy. Maybe you intended to make this request to the primary dashboard? Click below to be redirected to the primary site.",
241+
RetryEnabled: false,
242+
DashboardURL: opts.DashboardURL.String(),
243+
})
244+
})
236245

237246
return s, nil
238247
}

0 commit comments

Comments
 (0)