Skip to content

Commit 0c8b45b

Browse files
committed
Revert "Headscale: Added an option to set an Access-Control-Allow-Origin response header to enable Cross-Origin Resource Sharing (CORS)"
This reverts commit 4183039.
1 parent 09900cf commit 0c8b45b

File tree

3 files changed

+0
-24
lines changed

3 files changed

+0
-24
lines changed

config-example.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ grpc_listen_addr: 127.0.0.1:50443
4040
# are doing.
4141
grpc_allow_insecure: false
4242

43-
# The Access-Control-Allow-Origin header specifies which origins are allowed to access resources.
44-
# Options:
45-
# - "*" to allow access from any origin (not recommended for sensitive data).
46-
# - "http://example.com" to only allow access from a specific origin.
47-
# - "" to disable Cross-Origin Resource Sharing (CORS).
48-
Access-Control-Allow-Origin: ""
49-
5043
# The Noise section includes specific configuration for the
5144
# TS2021 Noise protocol
5245
noise:

hscontrol/app.go

-11
Original file line numberDiff line numberDiff line change
@@ -454,21 +454,10 @@ func (h *Headscale) ensureUnixSocketIsAbsent() error {
454454
return os.Remove(h.cfg.UnixSocket)
455455
}
456456

457-
func (h *Headscale) corsHeadersMiddleware(next http.Handler) http.Handler {
458-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
459-
w.Header().Set("Access-Control-Allow-Origin", h.cfg.AccessControlAllowOrigins)
460-
next.ServeHTTP(w, r)
461-
})
462-
}
463-
464457
func (h *Headscale) createRouter(grpcMux *grpcRuntime.ServeMux) *mux.Router {
465458
router := mux.NewRouter()
466459
router.Use(prometheusMiddleware)
467460

468-
if h.cfg.AccessControlAllowOrigins != "" {
469-
router.Use(h.corsHeadersMiddleware)
470-
}
471-
472461
router.HandleFunc(ts2021UpgradePath, h.NoiseUpgradeHandler).Methods(http.MethodPost, http.MethodGet)
473462

474463
router.HandleFunc("/health", h.HealthHandler).Methods(http.MethodGet)

hscontrol/types/config.go

-6
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ type Config struct {
6363
Log LogConfig
6464
DisableUpdateCheck bool
6565

66-
AccessControlAllowOrigins string
67-
6866
Database DatabaseConfig
6967

7068
DERP DERPConfig
@@ -305,8 +303,6 @@ func LoadConfig(path string, isFile bool) error {
305303
viper.SetDefault("tuning.batch_change_delay", "800ms")
306304
viper.SetDefault("tuning.node_mapsession_buffered_chan_size", 30)
307305

308-
viper.SetDefault("Access-Control-Allow-Origin", "")
309-
310306
viper.SetDefault("prefixes.allocation", string(IPAllocationStrategySequential))
311307

312308
if err := viper.ReadInConfig(); err != nil {
@@ -872,8 +868,6 @@ func LoadServerConfig() (*Config, error) {
872868
GRPCAllowInsecure: viper.GetBool("grpc_allow_insecure"),
873869
DisableUpdateCheck: false,
874870

875-
AccessControlAllowOrigins: viper.GetString("Access-Control-Allow-Origin"),
876-
877871
PrefixV4: prefix4,
878872
PrefixV6: prefix6,
879873
IPAllocation: IPAllocationStrategy(alloc),

0 commit comments

Comments
 (0)