diff --git a/packages/start/entry-server/index.ts b/packages/start/entry-server/index.ts index 25a1c2a46..648c79dde 100644 --- a/packages/start/entry-server/index.ts +++ b/packages/start/entry-server/index.ts @@ -1,4 +1,4 @@ -export { composeMiddleware, createHandler, default as StartServer } from "./StartServer"; +export { default as StartServer, composeMiddleware, createHandler } from "./StartServer"; export type { Middleware, MiddlewareFn, MiddlewareInput } from "./StartServer"; import { JSX } from "solid-js"; @@ -21,8 +21,8 @@ export const render = ( } ) => composeMiddleware([ - apiRoutes, inlineServerFunctions, + apiRoutes, import.meta.env.START_SSR === "async" ? _renderAsync(fn, options) : import.meta.env.START_SSR === "streaming" @@ -37,7 +37,7 @@ export const renderAsync = ( nonce?: string; renderId?: string; } -) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderAsync(fn, options)]); +) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderAsync(fn, options)]); export const renderStream = ( fn: (context: PageEvent) => JSX.Element, @@ -46,7 +46,7 @@ export const renderStream = ( nonce?: string; renderId?: string; } -) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderStream(fn, options)]); +) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderStream(fn, options)]); export const renderSync = ( fn: (context: PageEvent) => JSX.Element, @@ -55,4 +55,4 @@ export const renderSync = ( nonce?: string; renderId?: string; } -) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderSync(fn, options)]); +) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderSync(fn, options)]); diff --git a/packages/start/server/render.ts b/packages/start/server/render.ts index 8b2e8dc36..c6801079e 100644 --- a/packages/start/server/render.ts +++ b/packages/start/server/render.ts @@ -3,7 +3,7 @@ import { renderToStream, renderToString, renderToStringAsync } from "solid-js/we import { apiRoutes } from "../api/middleware"; import { inlineServerFunctions } from "../server/middleware"; import { redirect } from "../server/responses"; -import { FetchEvent, FETCH_EVENT, PageEvent } from "../server/types"; +import { FETCH_EVENT, FetchEvent, PageEvent } from "../server/types"; export function renderSync( fn: (context: PageEvent) => JSX.Element, @@ -12,8 +12,8 @@ export function renderSync( renderId?: string; } ) { - return () => apiRoutes({ - forward: inlineServerFunctions({ + return () => inlineServerFunctions({ + forward: apiRoutes({ async forward(event: FetchEvent): Promise { if ( !import.meta.env.DEV && @@ -53,8 +53,8 @@ export function renderAsync( renderId?: string; } ) { - return () => apiRoutes({ - forward: inlineServerFunctions({ + return () => inlineServerFunctions({ + forward: apiRoutes({ async forward(event: FetchEvent): Promise { if ( !import.meta.env.DEV && @@ -96,8 +96,8 @@ export function renderStream( onCompleteAll?: (info: { write: (v: string) => void }) => void; } = {} ) { - return () => apiRoutes({ - forward: inlineServerFunctions({ + return () => inlineServerFunctions({ + forward: apiRoutes({ async forward(event: FetchEvent): Promise { if ( !import.meta.env.DEV &&