Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cmd/explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/gobitfly/eth2-beaconchain-explorer/types"
"github.com/gobitfly/eth2-beaconchain-explorer/utils"
"github.com/gobitfly/eth2-beaconchain-explorer/version"
"github.com/phyber/negroni-gzip/gzip"
"github.com/zesik/proxyaddr"

"github.com/sirupsen/logrus"

Expand All @@ -36,10 +38,8 @@ import (
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/phyber/negroni-gzip/gzip"
"github.com/stripe/stripe-go/v72"
"github.com/urfave/negroni"
"github.com/zesik/proxyaddr"
)

func initStripe(http *mux.Router) error {
Expand Down Expand Up @@ -640,7 +640,23 @@ func main() {
_ = pa.Init(proxyaddr.CIDRLoopback)
n.Use(pa)

n.UseHandler(utils.SessionStore.SCS.LoadAndSave(router))
// Apply session middleware to dynamic pages only; skip for static font assets
// to avoid sending "Vary: Cookie" on cacheable static resources.
n.Use(negroni.HandlerFunc(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
p := r.URL.Path
if strings.HasPrefix(p, "/fonts/") ||
strings.HasPrefix(p, "/webfonts/") ||
strings.HasPrefix(p, "/img/") ||
strings.HasPrefix(p, "/css/") ||
strings.HasPrefix(p, "/theme/") ||
strings.HasPrefix(p, "/js/") {
next(w, r)
return
}
utils.SessionStore.SCS.LoadAndSave(next).ServeHTTP(w, r)
}))

n.UseHandler(router)

if utils.Config.Frontend.HttpWriteTimeout == 0 {
utils.Config.Frontend.HttpWriteTimeout = time.Second * 15
Expand Down
Loading