headers.go 407 B

1234567891011121314151617
  1. package middleware
  2. import (
  3. "fmt"
  4. "net/http"
  5. "strings"
  6. )
  7. // SetHeaders will set our global headers for web resources.
  8. func SetHeaders(w http.ResponseWriter, nonce string) {
  9. // Content security policy
  10. csp := []string{
  11. fmt.Sprintf("script-src '%s' 'self'", nonce),
  12. "worker-src 'self' blob:", // No single quotes around blob:
  13. }
  14. w.Header().Set("Content-Security-Policy", strings.Join(csp, "; "))
  15. }