mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
- Refactored to introduce handleSsr
function in @open-gsio/client/server/index.ts
for streamlined SSR handling.
- Replaced inline SSR logic in `AssetService.ts` with `handleSsr` import. - Enhanced `build:client` script to ensure server directory creation. - Updated dependencies and devDependencies across multiple packages for compatibility improvements.
This commit is contained in:
@@ -1,4 +1,20 @@
|
||||
import { renderPage } from 'vike/server';
|
||||
|
||||
// This is what makes SSR possible. It is consumed by @open-gsio/server
|
||||
export default renderPage;
|
||||
|
||||
export { handleSsr };
|
||||
|
||||
async function handleSsr(url: string, headers: Headers) {
|
||||
const pageContextInit = {
|
||||
urlOriginal: url,
|
||||
headersOriginal: headers,
|
||||
fetch: (...args: Parameters<typeof fetch>) => fetch(...args),
|
||||
};
|
||||
const pageContext = await renderPage(pageContextInit);
|
||||
const { httpResponse } = pageContext;
|
||||
const stream = httpResponse.getReadableWebStream();
|
||||
return new Response(stream, {
|
||||
headers: httpResponse.headers,
|
||||
status: httpResponse.statusCode,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user