Change CSP during development for faster source maps (#16982)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
813f60649f
Коммит
9aaf29ffb4
@@ -172,11 +172,19 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if h.IsStatic {
|
if h.IsStatic {
|
||||||
// Instruct the browser not to display us in an iframe unless is the same origin for anti-clickjacking
|
// Instruct the browser not to display us in an iframe unless is the same origin for anti-clickjacking
|
||||||
w.Header().Set("X-Frame-Options", "SAMEORIGIN")
|
w.Header().Set("X-Frame-Options", "SAMEORIGIN")
|
||||||
|
|
||||||
|
// Add unsafe-eval to the content security policy for faster source maps in development mode
|
||||||
|
devCSP := ""
|
||||||
|
if model.BuildNumber == "dev" {
|
||||||
|
devCSP = " 'unsafe-eval'"
|
||||||
|
}
|
||||||
|
|
||||||
// Set content security policy. This is also specified in the root.html of the webapp in a meta tag.
|
// Set content security policy. This is also specified in the root.html of the webapp in a meta tag.
|
||||||
w.Header().Set("Content-Security-Policy", fmt.Sprintf(
|
w.Header().Set("Content-Security-Policy", fmt.Sprintf(
|
||||||
"frame-ancestors 'self'; script-src 'self' cdn.rudderlabs.com%s%s",
|
"frame-ancestors 'self'; script-src 'self' cdn.rudderlabs.com%s%s%s",
|
||||||
cloudCSP,
|
cloudCSP,
|
||||||
h.cspShaDirective,
|
h.cspShaDirective,
|
||||||
|
devCSP,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
// All api response bodies will be JSON formatted by default
|
// All api response bodies will be JSON formatted by default
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user