Skip to content

chore: CORs option for yarn dev server #7630

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 10 commits into from
May 22, 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
Fix import order
  • Loading branch information
Emyrk committed May 22, 2023
commit f0a24edeeceee8bae22323b612c13d0b397f4098
3 changes: 2 additions & 1 deletion coderd/httpmw/cors.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package httpmw

import (
"github.com/go-chi/cors"
"net/http"

"github.com/go-chi/cors"
)

func CorsMW(allowAll bool, origins ...string) func(next http.Handler) http.Handler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we not have a CORS MW before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. We don't need CORs for the primary coderd, since all web requests are on the same domain.

The issue is the latency request checks for external proxies uses absolute urls. The local yarn dev server runs on a different port. So for the yarn dev server to hit the /latency endpoint, I need to turn on CORs.

This PR blocks all CORs requests to coderd by default if the flag is not true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was requested by @BrunoQuaresma. Without it, it was difficult for him to work on the workspace proxy UI.

Expand Down