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
Follow-up to #546.
Since the `netlifyRouterContext.set()` call was occurring in the server entry point built for
production but not in dev, and no default value was set for the context at construction time, using
middleware in dev would throw.
There's no ergonomic way to set up a `.set()` call dynamically on a context in dev, as far as I can
tell. This leaves the default value set at construction time as our only option.
To make this work, we can use the global `Netlify.context`. However, this is only accessible during
a request-response lifecycle, not in module scope at module init time. So this commit simply changes
`netlifyRouterContext` to a function `getNetlifyRouterContext()` so that we can lazily construct the
context with a default value of `Netlify.context` during a request lifecycle.
To be clear, the Netlify router context will only work in local dev when using either the Netlify
CLI or `@netlify/vite-plugin`.
0 commit comments