You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
407 B
17 lines
407 B
package middleware |
|
|
|
import ( |
|
"fmt" |
|
"net/http" |
|
"strings" |
|
) |
|
|
|
// SetHeaders will set our global headers for web resources. |
|
func SetHeaders(w http.ResponseWriter, nonce string) { |
|
// Content security policy |
|
csp := []string{ |
|
fmt.Sprintf("script-src '%s' 'self'", nonce), |
|
"worker-src 'self' blob:", // No single quotes around blob: |
|
} |
|
w.Header().Set("Content-Security-Policy", strings.Join(csp, "; ")) |
|
}
|
|
|