Ghost Website breaks when worker is enable

Hi guys :wave:,

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 => {

 * 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 :point_right: 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 :chile:

I believe that worker is only good for a GET, and should be active on an appropriate route. You may need to create a dummy route for whatever Ghost’s admin directory is and set it for No Worker.

1 Like

Thanks for the :rocket: reply ! I’ll try your recommendation.

1 Like

OK, thank you.

I finally remove the wildcard (*) from the routes, and I added each specific route (without wildcard).

Now it works great. Thank you ! :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.