veryfront 0.1.32 → 0.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-html-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-html-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAMrD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,gDAAgD;IAChD,GAAG,EAAE,GAAG,CAAC;IACT,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA2FzE"}
1
+ {"version":3,"file":"markdown-html-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-html-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAMrD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,gDAAgD;IAChD,GAAG,EAAE,GAAG,CAAC;IACT,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAoED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA2FzE"}
@@ -25,7 +25,7 @@ function detectTheme(req, url) {
25
25
  * Injected when embedded in Studio (`studio_embed=true`) or for standalone
26
26
  * markdown/MDX pages so the edit button and editor features are available.
27
27
  */
28
- function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
28
+ function buildStudioScript(req, url, projectId, filePath, branchId, requestHost) {
29
29
  const studioEmbed = url.searchParams.get("studio_embed") === "true";
30
30
  const isMarkdown = /\.mdx?$/i.test(filePath);
31
31
  if (!studioEmbed && !isMarkdown)
@@ -37,7 +37,10 @@ function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
37
37
  const canonicalProjectId = queryProjectId || projectId;
38
38
  const canonicalPageId = queryFileId || filePath;
39
39
  // Compute Yjs connection config for the bridge to self-connect
40
- const wsProtocol = url.protocol === "https:" ? "wss" : "ws";
40
+ // Use x-forwarded-proto to detect the public-facing protocol (internal K8s URL is always http)
41
+ const forwardedProto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
42
+ const isSecure = forwardedProto === "https" || url.protocol === "https:";
43
+ const wsProtocol = isSecure ? "wss" : "ws";
41
44
  const host = requestHost || url.host;
42
45
  const wsUrl = `${wsProtocol}://${host}/api/ws/${canonicalProjectId}/yjs`;
43
46
  const yjsGuid = branchId ? `${canonicalProjectId}:${branchId}` : canonicalProjectId;
@@ -59,7 +62,7 @@ function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
59
62
  export function generateMarkdownHtml(options) {
60
63
  const { rawHtml, title, description, request, url, projectId, filePath, branchId, requestHost } = options;
61
64
  const theme = detectTheme(request, url);
62
- const studioScript = buildStudioScript(url, projectId, filePath, branchId, requestHost);
65
+ const studioScript = buildStudioScript(request, url, projectId, filePath, branchId, requestHost);
63
66
  const themeAttrs = theme ? ` data-theme="${theme}" style="color-scheme: ${theme};"` : "";
64
67
  return `<!DOCTYPE html>
65
68
  <html lang="en"${themeAttrs}>
@@ -109,7 +109,7 @@ export class MarkdownPreviewHandler extends BaseHandler {
109
109
  projectId: ctx.projectSlug || ctx.projectId || "markdown-preview",
110
110
  filePath,
111
111
  branchId: ctx.parsedDomain?.branch ?? null,
112
- requestHost: url.host,
112
+ requestHost: req.headers.get("x-forwarded-host") || req.headers.get("host") || url.host,
113
113
  });
114
114
  const responseBuilder = this.createResponseBuilder(ctx)
115
115
  .withCache("no-cache")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -63,6 +63,7 @@ function detectTheme(req: dntShim.Request, url: URL): "light" | "dark" | null {
63
63
  * markdown/MDX pages so the edit button and editor features are available.
64
64
  */
65
65
  function buildStudioScript(
66
+ req: dntShim.Request,
66
67
  url: URL,
67
68
  projectId: string,
68
69
  filePath: string,
@@ -81,7 +82,10 @@ function buildStudioScript(
81
82
  const canonicalPageId = queryFileId || filePath;
82
83
 
83
84
  // Compute Yjs connection config for the bridge to self-connect
84
- const wsProtocol = url.protocol === "https:" ? "wss" : "ws";
85
+ // Use x-forwarded-proto to detect the public-facing protocol (internal K8s URL is always http)
86
+ const forwardedProto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
87
+ const isSecure = forwardedProto === "https" || url.protocol === "https:";
88
+ const wsProtocol = isSecure ? "wss" : "ws";
85
89
  const host = requestHost || url.host;
86
90
  const wsUrl = `${wsProtocol}://${host}/api/ws/${canonicalProjectId}/yjs`;
87
91
  const yjsGuid = branchId ? `${canonicalProjectId}:${branchId}` : canonicalProjectId;
@@ -109,7 +113,7 @@ export function generateMarkdownHtml(options: MarkdownHtmlOptions): string {
109
113
  options;
110
114
 
111
115
  const theme = detectTheme(request, url);
112
- const studioScript = buildStudioScript(url, projectId, filePath, branchId, requestHost);
116
+ const studioScript = buildStudioScript(request, url, projectId, filePath, branchId, requestHost);
113
117
  const themeAttrs = theme ? ` data-theme="${theme}" style="color-scheme: ${theme};"` : "";
114
118
 
115
119
  return `<!DOCTYPE html>
@@ -160,7 +160,7 @@ export class MarkdownPreviewHandler extends BaseHandler {
160
160
  projectId: ctx.projectSlug || ctx.projectId || "markdown-preview",
161
161
  filePath,
162
162
  branchId: ctx.parsedDomain?.branch ?? null,
163
- requestHost: url.host,
163
+ requestHost: req.headers.get("x-forwarded-host") || req.headers.get("host") || url.host,
164
164
  });
165
165
 
166
166
  const responseBuilder = this.createResponseBuilder(ctx)