javascript - React Server.js 索引文件更改?
问题描述
server
.disable('x-powered-by')
.use(express.static(process.env.RAZZLE_PUBLIC_DIR))
.get('/*', (req, res) => {
const context = {}
const markup = renderToStaticNodeStream(
<StaticRouter location={req.url} context={context}>
<App />
</StaticRouter>
);
if (context.url) {
// Somewhere a `<Redirect>` was rendered
redirect(301, context.url);
} else {
res.status(200).send(
`<!doctype html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<title>{meta.title}</title>
<meta name="title" content={meta.title} />
<meta name="description" content={meta.description} />
<meta property="og:title" content={meta.title} />
<meta property="og:image" content={meta.image} />
<meta property="og:description" content={meta.description} />
<meta property="og:url" content={meta.url} />
我正在尝试根据我的页面设置元标记以做出反应。当我从 server.js 渲染我的反应应用程序时。我现在可以根据页面更改元标记内容吗?
解决方案
推荐阅读
- javascript - Angular Firestore 加入集合不起作用
- arduino - 从 Arduino IDE 上传到 ESP8266 时出错
- amazon-web-services - 将数据从 AWS IoT 发送到 SQS FiFo 时出错
- python - Kivy Image 不显示某些 jpg 图像
- angular - 当在 Angular 8 中有导入的样式表时,如何使用 SCSS 更改字体颜色?
- lua - 安装 Lua 库的特定分支
- python - 如何为函数的每次交互计时?
- java - Java 保持 pojo 数据存储独立
- c# - 是否可以从 ASP.NET MVC 中的视图返回多个项目
- arrays - 如何从列表中删除所有重复项并使用 Python 更改对重复项的所有引用