mirror of
https://github.com/usememos/memos.git
synced 2025-01-01 01:51:46 +08:00
fix: set csp header only for resource (#836)
This commit is contained in:
parent
119603da5d
commit
99d9cc9168
2 changed files with 1 additions and 4 deletions
|
@ -265,6 +265,7 @@ func (s *Server) registerResourcePublicRoutes(g *echo.Group) {
|
||||||
c.Response().Writer.Header().Set("Content-Type", resource.Type)
|
c.Response().Writer.Header().Set("Content-Type", resource.Type)
|
||||||
c.Response().Writer.WriteHeader(http.StatusOK)
|
c.Response().Writer.WriteHeader(http.StatusOK)
|
||||||
c.Response().Writer.Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")
|
c.Response().Writer.Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")
|
||||||
|
c.Response().Writer.Header().Set(echo.HeaderContentSecurityPolicy, "default-src 'self'")
|
||||||
if _, err := c.Response().Writer.Write(resource.Blob); err != nil {
|
if _, err := c.Response().Writer.Write(resource.Blob); err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to write response").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to write response").SetInternal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,6 @@ func NewServer(profile *profile.Profile) *Server {
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
e.Use(middleware.SecureWithConfig(middleware.SecureConfig{
|
|
||||||
ContentSecurityPolicy: "default-src 'self'",
|
|
||||||
}))
|
|
||||||
|
|
||||||
embedFrontend(e)
|
embedFrontend(e)
|
||||||
|
|
||||||
// In dev mode, set the const secret key to make signin session persistence.
|
// In dev mode, set the const secret key to make signin session persistence.
|
||||||
|
|
Loading…
Reference in a new issue