Skip to content

feat: allow bypassing current CORS magic based on template config #18706

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 23 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
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
fix linting
Signed-off-by: Callum Styan <callumstyan@gmail.com>
  • Loading branch information
cstyan committed Jul 9, 2025
commit a5ad58b0069a07c3f69b5656b3829052c552f315
4 changes: 2 additions & 2 deletions coderd/workspaceapps/apptest/apptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
})

// Update the template CORS behavior.
b := codersdk.CORSBehavior(tc.behavior)
b := tc.behavior
template, err := appDetails.SDKClient.UpdateTemplateMeta(ctx, appDetails.Workspace.TemplateID, codersdk.UpdateTemplateMeta{
CORSBehavior: &b,
})
Expand Down Expand Up @@ -1856,7 +1856,7 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
require.NoError(t, err)

// Update the template CORS behavior.
b := codersdk.CORSBehavior(tc.behavior)
b := tc.behavior
template, err := appDetails.SDKClient.UpdateTemplateMeta(ctx, appDetails.Workspace.TemplateID, codersdk.UpdateTemplateMeta{
CORSBehavior: &b,
})
Expand Down
4 changes: 0 additions & 4 deletions coderd/workspaceapps/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,10 @@ func (s *Server) determineCORSBehavior(token *SignedToken, app appurl.Applicatio

switch behavior {
case codersdk.CORSBehaviorPassthru:
fmt.Println("passthru")
// Bypass the CORS middleware.
next.ServeHTTP(rw, r)
return
default:
fmt.Println("default cors")

// Apply the CORS middleware.
corsHandler.ServeHTTP(rw, r)
}
Expand Down Expand Up @@ -597,7 +594,6 @@ func (s *Server) proxyWorkspaceApp(rw http.ResponseWriter, r *http.Request, appT
proxy.ModifyResponse = func(r *http.Response) error {
// If passthru behavior is set, disable our CORS header stripping.
if cors.HasBehavior(r.Request.Context(), codersdk.CORSBehaviorPassthru) {
fmt.Println("not modifying headers!!!")
return nil
}
r.Header.Del(httpmw.AccessControlAllowOriginHeader)
Expand Down
Loading