You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Actually I had the kind of same realisation on my project, and I discovered that files coming from client/ are actually served by sapper.middleware.
You can safely (or maybe I missed something) serve them before going through sapper.middleware.
If you are using express, you can do this
app.use(sirv("static",{ dev })).use("/client",.use("/client",sirv(`__sapper__/${dev ? "dev" : "build"}/client`,{ dev }))).use(load_session,sapper.middleware({session: rq=>rq._sapper_session,}),)
If you are using polka, it won't work (have a look here to understand why)
For /logo-192.png it is weird as it should be served by the first sirv("static", { dev })
I would just like to add that I have issues with session middleware being applied to static .js assets as well. My server handles sessions by itself, but because the middleware is applied on all the static .js assets it becomes very slow when loading the site from a clean tab.
The fix provided by @bcharbonnier works, but does not seem idiomatic to me.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I fetch current session from backend and then pass it into
sapper.middleware
:I use
load_session
as middleware becausesapper.middleware
isn't awaitableBut major issue I found is that session is also requested for each static asset:
The way to fix coming up to my mind is make
session.middleware
to consume a promise and then resolve it only when we actually need the session.The text was updated successfully, but these errors were encountered: