Skip to content

chore: Allow cors requests to workspace proxies for latency checks #7484

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

Merged
merged 5 commits into from
May 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Add cors to workspace proxies to allow for latency checks
  • Loading branch information
Emyrk committed May 10, 2023
commit 0c6bc96d69cc4c9896fc26e61578a5bb46779045
16 changes: 16 additions & 0 deletions enterprise/wsproxy/wsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"strings"
"time"

"github.com/go-chi/cors"

"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -197,6 +199,20 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
httpmw.ExtractRealIP(s.Options.RealIPConfig),
httpmw.Logger(s.Logger),
httpmw.Prometheus(s.PrometheusRegistry),
// The primary coderd dashboard needs to make some GET requests to
// the workspace proxies to check latency.
cors.Handler(cors.Options{
AllowedOrigins: []string{
// Allow the dashboard to make requests to the proxy for latency
// checks.
opts.DashboardURL.String(),
},
// Only allow GET requests for latency checks.
AllowedMethods: []string{http.MethodGet},
AllowedHeaders: []string{"Accept", "Content-Type"},
// Do not send any cookies
AllowCredentials: false,
}),

// HandleSubdomain is a middleware that handles all requests to the
// subdomain-based workspace apps.
Expand Down