Hi guys ,
I wanted to replace some HTML text for my Ghost blog site, so I followed this hint for doing some text replacement:
addEventListener('fetch', event => {
event.passThroughOnException()
event.respondWith(handleRequest(event.request))
})
/**
* Fetch and log a given request object
* @param {Request} request
*/
async function handleRequest(request) {
const response = await fetch(request)
var html = await response.text()
// Simple replacement regex
html = html.replace( /Source Phrase/g , 'Target Phrase')')
// return modified response
return new Response(html, {
headers: response.headers
})
}
But, after I enable this worker:
- the Ghost admin section won’t start
it returns an empty page.
- Images are not displayed in the homepage.
I checked similar issues in other posts, like this, so, I checked:
- Rocked loader is disabled
- Mirage is disabled
- Most of configuration settings are disable (like JS, CSS minification, etc).
Any idea why this happens ?
Thanks for any help or advice. Regards from