我想将CRA捆绑软件部署到s3并从Cloudfront提供服务。但是索引文件应该是快速视图(模板,我想向其中添加一些数据)。我发现的所有解决方案都采用无服务器或直接从节点提供CRA索引。
因此,我需要将索引作为模板并包含要捆绑的Cloudfront URL。我该如何实现?
最佳答案
如果您需要创建和index.html,则无需模板即可
app.get('/', function(req, res) {
res.type('text/html');
res.send('<html>...</html>');
});
或使用类似的模板
玉
doctype html
html
head
title Jade Page
link(href='https://cloudf../css/main.css', rel='stylesheet')
body
h1 This page is produced by Jade engine
p some paragraph here..
资料来源:https://www.tutorialsteacher.com/nodejs/jade-template-engine
哈巴狗
html
head
title= title
link(href='https://cloudf../css/main.css' rel='stylesheet')
body
h1= message
app.get('/', function (req, res) {
res.render('index', { title: 'Hey', message: 'Hello there!'});
});
https://scriptverse.academy/tutorials/nodejs-express-pug.html
https://stackoverflow.com/a/38047123/3957754