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