Serverless Pre-Rendering Without Next.js #115
-
Hi! I read the blog post on SPR and I haven't been this excited about a feature in a long time! The example project uses Next.js, which is great, but for super simple projects I was wondering how we can configure a serverless function to handle the HTML response for a page / route? For example, I know we can create a file in the "/api" folder and that's all it takes to setup a serverless function, but is there documentation on how we can set a serverless function to be responsible for the HTML response for a given url? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 7 replies
-
Hi @LearnWebCode You can return an HTML string from the function and set the appropriate module.exports = (req, res) => {
res.setHeader('content-type', 'text/html')
res.setHeader('cache-control', 's-maxage=3600, stale-while-revalidate')
res.send(`
<html>
<body><h1>yo</h1></body>
</html>
`)
} |
Beta Was this translation helpful? Give feedback.
Hi @LearnWebCode You can return an HTML string from the function and set the appropriate
content-type