-
Notifications
You must be signed in to change notification settings - Fork 887
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
Conversation
Adds a flag to set CORs headers to `*` for yarn dev servers
coderd/httpmw/cors.go
Outdated
"net/http" | ||
) | ||
|
||
func CorsMW(allowAll bool, origins ...string) func(next http.Handler) http.Handler { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Yarn dev server cannot request latency check endpoint because of CORs and CSP.
Add a flag to allow all external requests for yarn dev server to work correctly. This is a dangerous and hidden flag for dev use only.