fix: update FRONTEND_BASE_URL and enhance SSR route handling
This commit is contained in:
@@ -12,7 +12,7 @@ data:
|
||||
STREAM_INTERNAL_AUTH_MARKER: "stream_maker_123xxx"
|
||||
STREAM_UI_JWT_SECRET: "xxx_stream_maker_123_xxx"
|
||||
STREAM_UI_REDIS_URL: "redis://:pass123@47.84.62.226:6379/3"
|
||||
FRONTEND_BASE_URL: "https://hlstiktok.com"
|
||||
FRONTEND_BASE_URL: "http://stream-ui-svc"
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
|
||||
@@ -69,26 +69,26 @@ export const loadCssByModules = (m: Array<string>) => {
|
||||
});
|
||||
return cssFiles;
|
||||
}
|
||||
export function buildBootstrapScript() {
|
||||
export function buildBootstrapScript(modulesList: Array<string> = []) {
|
||||
let script = "";
|
||||
let styles = "";
|
||||
let manifest: Manifest = import.meta.env.PROD
|
||||
? loadManifest() ?? {}
|
||||
: {
|
||||
"0": {
|
||||
file: "@vite/client",
|
||||
isEntry: true,
|
||||
css: [],
|
||||
imports: [],
|
||||
dynamicImports: [],
|
||||
assets: [],
|
||||
},
|
||||
"1": {
|
||||
file: "src/client.ts",
|
||||
isEntry: true,
|
||||
css: [],
|
||||
},
|
||||
};
|
||||
"0": {
|
||||
file: "@vite/client",
|
||||
isEntry: true,
|
||||
css: [],
|
||||
imports: [],
|
||||
dynamicImports: [],
|
||||
assets: [],
|
||||
},
|
||||
"1": {
|
||||
file: "src/client.ts",
|
||||
isEntry: true,
|
||||
css: [],
|
||||
},
|
||||
};
|
||||
Object.values(manifest).forEach((chunk) => {
|
||||
if (chunk.isEntry) {
|
||||
script += `<script type="module" src="/${chunk.file}"></script>`;
|
||||
@@ -96,10 +96,12 @@ export function buildBootstrapScript() {
|
||||
styles += `<link rel="stylesheet" crossorigin href="/${cssFile}">`;
|
||||
});
|
||||
} else {
|
||||
script += `<link rel="modulepreload" href="/${chunk.file}">`;
|
||||
(chunk.css || []).forEach((cssFile) => {
|
||||
styles += `<link rel="preload" as="style" href="/${cssFile}">`;
|
||||
});
|
||||
if ((chunk.src && modulesList.includes(chunk.src))) {
|
||||
script += `<link rel="modulepreload" href="/${chunk.file}">`;
|
||||
(chunk.css || []).forEach((cssFile) => {
|
||||
styles += `<link rel="preload" as="style" href="/${cssFile}">`;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return styles + script;
|
||||
|
||||
@@ -35,9 +35,14 @@ export function registerSSRRoutes(app: Hono) {
|
||||
const ctx: Record<string, any> = {};
|
||||
const appStream = renderToWebStream(vueApp, ctx);
|
||||
|
||||
//Base url affter cloudflare workers support is added
|
||||
const protocall = c.req.header("x-forwarded-proto") || new URL(c.req.url).protocol.replace(":", "");
|
||||
const host = c.req.header("x-forwarded-host") || c.req.header("host") || new URL(c.req.url).host;
|
||||
const origin = `${protocall}://${host}`;
|
||||
|
||||
// HTML Head
|
||||
await stream.write(`<!DOCTYPE html><html lang='${auth.user?.language ?? lang}'><head>`);
|
||||
await stream.write("<base href='" + url.origin + "'/>");
|
||||
await stream.write("<base href='" + origin + "'/>");
|
||||
|
||||
// SSR Head tags
|
||||
const headResult = await renderSSRHead(head);
|
||||
@@ -47,9 +52,8 @@ export function registerSSRRoutes(app: Hono) {
|
||||
await stream.write('<link rel="icon" href="/favicon.ico">');
|
||||
await stream.write(`<link rel="preconnect" href="https://fonts.googleapis.com" />`);
|
||||
await stream.write(`<link href="https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap" rel="stylesheet" />`);
|
||||
|
||||
// Bootstrap scripts
|
||||
await stream.write(buildBootstrapScript());
|
||||
await stream.write(buildBootstrapScript(Array.from(ctx.modules || [])));
|
||||
|
||||
// Body start
|
||||
await stream.write(`</head><body class='${bodyClass}'>`);
|
||||
|
||||
@@ -38,14 +38,22 @@ export default defineConfig((env) => {
|
||||
environments: {
|
||||
client: {
|
||||
build: {
|
||||
modulePreload: false,
|
||||
outDir: "dist/client",
|
||||
rollupOptions: {
|
||||
input: { index: "/src/client.ts" },
|
||||
output: {
|
||||
entryFileNames: 'assets/[hash].js',
|
||||
chunkFileNames: 'assets/[hash].js',
|
||||
assetFileNames: 'assets/[name].[ext]',
|
||||
},
|
||||
},
|
||||
|
||||
},
|
||||
},
|
||||
server: {
|
||||
build: {
|
||||
modulePreload: false,
|
||||
outDir: "dist/server",
|
||||
copyPublicDir: false,
|
||||
rollupOptions: {
|
||||
|
||||
Reference in New Issue
Block a user