Using Cloudflare Worker to respond with another site

Hi there!

I’m currently trying to serve a different webpage than the one the user entered into the adress bar with a Cloudflare worker like this. It works like a charm for plain HTML sites, but the page i want to load is actually a react app. This is where i’m stuck, how can i load a react app with a Cloudflare worker?

Many thanks!

No one? :frowning:
I thought this is a comming thing to do

Yes, proxying is common use case (just make sure you’re legally allowed to do so!).

When you request the HTML, you’re not also proxying the scripts (react) that the HTML loads. You’ll need to process the HTML in the worker and replace the URLs with your worker URL so that they are also proxied.

This is a very basic thing to do, that’s why no one’s replying.


Oh haha, I’m new to all this. Thank you for your answer, I appreciate it. Could you maybe point me to an example or blog post I can read?

Or is this what you mean?

You can use the HTML rewriter or just parse the strings in JS manually, it’s up to you.

1 Like

Nice, i’ll try this and get back to with more questions if that’s ok? :slight_smile:

Just ask, someone might respond :slight_smile:

If you get stuck you can also join the discord server here for help:

1 Like

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