Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore(server): enable renderer for all deployment (#8283)

forehalo03ac9bc4a12d
diff --git a/.github/helm/affine/templates/ingress.yaml b/.github/helm/affine/templates/ingress.yaml
index 5b35a8a703..8a3f03a533 100644
--- a/.github/helm/affine/templates/ingress.yaml
+++ b/.github/helm/affine/templates/ingress.yaml
@@ -60,15 +60,20 @@ spec:
name: affine-graphql
port:
number: {{ .Values.graphql.service.port }}
- {{- if eq .Values.global.app.buildType "canary" }}
- - path: /workspace
- pathType: Prefix
+ - path: /workspace/([^/]+)/(home|all|search|collection|tag|trash)
+ pathType: ImplementationSpecific
+ backend:
+ service:
+ name: affine-web
+ port:
+ number: {{ .Values.web.service.port }}
+ - path: /workspace/([^/]+)/.+
+ pathType: ImplementationSpecific
backend:
service:
name: affine-renderer
port:
- number: {{ .Values.graphql.service.port }}
- {{- end }}
+ number: {{ .Values.renderer.service.port }}
- path: /
pathType: Prefix
backend:
diff --git a/packages/backend/server/src/core/doc-renderer/controller.ts b/packages/backend/server/src/core/doc-renderer/controller.ts
index fff14f545a..85035ed05e 100644
--- a/packages/backend/server/src/core/doc-renderer/controller.ts
+++ b/packages/backend/server/src/core/doc-renderer/controller.ts
@@ -33,7 +33,7 @@ const defaultAssets: HtmlAssets = {
description: '',
};
-@Controller('/workspace/:workspaceId/:docId')
+@Controller('/workspace')
export class DocRendererController {
private readonly logger = new Logger(DocRendererController.name);
private readonly webAssets: HtmlAssets = defaultAssets;
@@ -68,7 +68,7 @@ export class DocRendererController {
}
@Public()
- @Get()
+ @Get('/:workspaceId/:docId')
async render(
@Req() req: Request,
@Res() res: Response,
@@ -87,7 +87,7 @@ export class DocRendererController {
try {
opts =
workspaceId === docId
- ? await this.renderWorkspace(workspaceId)
+ ? await this.getWorkspaceContent(workspaceId)
: await this.getPageContent(workspaceId, docId);
metrics.doc.counter('render').add(1);
} catch (e) {
@@ -123,7 +123,7 @@ export class DocRendererController {
return null;
}
- private async renderWorkspace(
+ private async getWorkspaceContent(
workspaceId: string
): Promise<RenderOptions | null> {
const allowUrlPreview = await this.permission.allowUrlPreview(workspaceId);