a year ago
Evaluate cookies and headers with Dynamic Scopes
Dynamic Scopes, now in Beta, lets you evaluate the contents of headers and cookies using a JS function, enabling you to define scopes dynamically. Learn more over in the docs.
import { Config } from 'stellate' const config: Config = { config: { scopes: { // ctx is an object with the following properties: // - headers: an object with all headers of the request // - cookies: an object with all cookies of the request AUTHENTICATED: (ctx) => { const userId = ctx.cookies.uid if (!userId || userId.startsWith('lo_')) { return 'UNAUTHENTICATED' } return userId }, }, }, } export default config