2021-08-31 04:43:28 +02:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
2021-09-18 19:06:47 +02:00
|
|
|
"fmt"
|
2021-08-31 04:43:28 +02:00
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetHeaders will set our global headers for web resources.
|
2022-12-13 01:57:17 +01:00
|
|
|
func SetHeaders(w http.ResponseWriter, nonce string) {
|
2021-08-31 04:43:28 +02:00
|
|
|
// Content security policy
|
|
|
|
csp := []string{
|
2022-12-13 01:57:17 +01:00
|
|
|
fmt.Sprintf("script-src '%s' 'self'", nonce),
|
2021-08-31 04:43:28 +02:00
|
|
|
"worker-src 'self' blob:", // No single quotes around blob:
|
|
|
|
}
|
|
|
|
w.Header().Set("Content-Security-Policy", strings.Join(csp, "; "))
|
|
|
|
}
|