This commit is contained in:
lbenedar
2026-03-05 18:11:34 +03:00
parent b644c0384e
commit 3c7cb22298
3 changed files with 8 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ func main() {
}
infoLog.Printf("Starting server on %s", cfg.addr)
err = srv.ListenAndServe()
err = srv.ListenAndServeTLS("./tls/cert.pem", "./tls/key.pem")
errorLog.Fatal(err)
}

View File

@@ -7,12 +7,12 @@ import (
func secureHeaders(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Security-Policy",
"default-src 'self'; style-src 'self' fonts.googleapis.com; font-src fonts.gstatic.com")
w.Header().Set("Referrer-Policy", "origin-when-cross-origin")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("X-Frame-Options", "deny")
w.Header().Set("X-XSS-Protection", "0")
//w.Header().Set("Content-Security-Policy",
// "default-src 'self'; style-src 'self' fonts.googleapis.com; font-src fonts.gstatic.com")
//w.Header().Set("Referrer-Policy", "origin-when-cross-origin")
//w.Header().Set("X-Content-Type-Options", "nosniff")
//w.Header().Set("X-Frame-Options", "deny")
//w.Header().Set("X-XSS-Protection", "0")
next.ServeHTTP(w, r)
})

View File

@@ -15,7 +15,7 @@ func (app *application) routes() http.Handler {
})
fileServer := http.FileServer(http.Dir("./ui/static/"))
router.Handler(http.MethodGet, "/static/", http.StripPrefix("/static", fileServer))
router.Handler(http.MethodGet, "/static/*filepath", http.StripPrefix("/static", fileServer))
dynamic := alice.New(app.sessionManager.LoadAndSave)