See the comment in the code below. Is that possible?
// Inject 'content' where content comes from a dynamic call to an API
.match("/example-react-progressive-web-apps-ecommerce/", ({ proxy }) => {
proxy("origin", {
path: "/company",
transformResponse: (res, req) => {
const $ = cheerio.load(res.body)
// Remove everything but the header and footer
$(".section").remove()
// Insert our new div that will house our new content
$(".navbar-wrapper").after('<div id="main-content-container"></div>')
// Change page title
$("title").text("Example eCommerce PWAs")
// Rewrite links in original page
$("a").each(function () {
let old_href = $(this).attr("href")
if (old_href[0] === "/") {
let new_href = "https://www.moovweb.com" + old_href
$(this).attr("href", new_href)
}
})
// Inject 'content' where content comes from a dynamic call to an API
$('#main-content-container').append(content)
res.body = $.html()
res.setHeader("content-length", res.body.length)
},
})
})