How would one use Workers to server static HTML without hitting the origin server?
I’d really appreciate a sample script with a placeholder for <html>EVERYTHING</html>
How would one use Workers to server static HTML without hitting the origin server?
I’d really appreciate a sample script with a placeholder for <html>EVERYTHING</html>
Sure thing, try this:
addEventListener('fetch', event => {
event.respondWith(fetchAndLog(event.request))
})
async function fetchAndLog(request) {
return new Response("<html>EVERYTHING</html>", {
headers: {
'Content-Type': 'text/html'
}
})
}