File size: 598 Bytes
5710dd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/** A pre-gzipped self-contained SPA HTML page, served from memory. */
export interface WebAsset {
  /** gzip-compressed bytes of the single-file index.html. */
  readonly gzipped: Uint8Array;
}

/** Serve the embedded SPA for any non-/api GET (SPA fallback: same page for
 *  every client route, since the bundle is a single self-contained HTML). */
export function serveWebAsset(asset: WebAsset): Response {
  return new Response(asset.gzipped, {
    headers: {
      'content-type': 'text/html; charset=utf-8',
      'content-encoding': 'gzip',
      'cache-control': 'no-store',
    },
  });
}