问题描述
我正在使用ServeStaticModule发送回index.html文件。我想为Facebook预览添加自定义元标记。我尝试在客户端执行此操作,但由于Facebook使用旧的标题和说明,而不是在客户端进行了修改的新标题和说明,因此该方法不起作用。客户端在React中。
有什么建议吗?
解决方法
您必须使用模板引擎-read more
模板示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App</title>
</head>
<body>
{{ message }}
</body>
</html>
app.controller.ts
import { Get,Controller,Render } from '@nestjs/common';
@Controller()
export class AppController {
@Get()
@Render('index')
root() {
return { message: 'Hello world!' };
}
}