Skip to content

Commit

Permalink
Cleanup createStreamingHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 committed May 21, 2024
1 parent 12e4eea commit 71fd715
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/vite/src/streaming/createReactStreamingHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { HTTPMethod } from 'find-my-way'
import { createIsbotFromList, list as isbotList } from 'isbot'
import type { ViteDevServer } from 'vite'

import type { ServerAuthState } from '@redwoodjs/auth'
import { middlewareDefaultAuthProviderState } from '@redwoodjs/auth'
import type { RouteSpec, RWRouteManifestItem } from '@redwoodjs/internal'
import { getAppRouteHook, getConfig, getPaths } from '@redwoodjs/project-config'
Expand Down Expand Up @@ -71,7 +72,14 @@ export const createReactStreamingHandler = async (
// @NOTE: we are returning a FetchAPI handler
return async (req: Request) => {
let mwResponse = MiddlewareResponse.next()
let decodedAuthState = middlewareDefaultAuthProviderState

// Default auth state
let decodedAuthState: ServerAuthState = {
...middlewareDefaultAuthProviderState,
cookieHeader: req.headers.get('cookie'),
roles: [],
}

// @TODO: Make the currentRoute 404?
let currentRoute: RWRouteManifestItem | undefined
let parsedParams: any = {}
Expand Down Expand Up @@ -188,11 +196,7 @@ export const createReactStreamingHandler = async (
cssLinks,
isProd,
jsBundles,
authState: {
roles: [],
cookieHeader: req.headers.get('cookie'),
...decodedAuthState,
},
authState: decodedAuthState,
},
{
waitForAllReady: isSeoCrawler,
Expand Down

0 comments on commit 71fd715

Please sign in to comment.