mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: CORs option for yarn dev server (#7630)
* chore: Yarn dev servers require CORs headers for external proxies Adds a flag to set CORs headers to `*` for yarn dev servers
This commit is contained in:
@ -6,7 +6,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func LatencyCheck(allowedOrigins ...*url.URL) http.HandlerFunc {
|
||||
// LatencyCheck is an endpoint for the web ui to measure latency with.
|
||||
// allowAll allows any Origin to get timing information. The allowAll should
|
||||
// only be set in dev modes.
|
||||
//
|
||||
//nolint:revive
|
||||
func LatencyCheck(allowAll bool, allowedOrigins ...*url.URL) http.HandlerFunc {
|
||||
allowed := make([]string, 0, len(allowedOrigins))
|
||||
for _, origin := range allowedOrigins {
|
||||
// Allow the origin without a path
|
||||
@ -14,6 +19,9 @@ func LatencyCheck(allowedOrigins ...*url.URL) http.HandlerFunc {
|
||||
tmp.Path = ""
|
||||
allowed = append(allowed, strings.TrimSuffix(origin.String(), "/"))
|
||||
}
|
||||
if allowAll {
|
||||
allowed = append(allowed, "*")
|
||||
}
|
||||
origins := strings.Join(allowed, ",")
|
||||
return func(rw http.ResponseWriter, r *http.Request) {
|
||||
// Allowing timing information to be shared. This allows the browser
|
||||
|
Reference in New Issue
Block a user