[Solved]Trying to fetch a react-app (static site) from s3 public bucket inside CloudFlare worker.
Hey guys, it's been two days and I can't seem to fetch my react web app deployed in s3 using CloudFlare worker. 😭 Can someone help with the correct way to do it?
I'm stuck at this error 😢 , see the ss. It seems I am able to download html, css and js bundle but browser is not able to parse them.
So far I've tried these things:
- make sure the content-type is correct for all the assets i.e text/html, text/css and application/javascript by creating a
new Response(response.text(), {...response, headers:myHeaders})
- return fetch(bucketUrl, originalRequest)
- bang my head on table, wall and bed
- scratch my head
- about to cry in the corner 😭
here's the route that triggers the worker. https://app.nrj.life
Please, if someone has done it guide me. 🙏
My goal is to fetch the react-app and redirect users to mydomain/subroute with that fetched content.Brand fit
Web site created using create-react-app
![No description](https://cdn.answeroverflow.com/1152530599018500187/image.png)
1 Reply
yeah bro
I'm tinkering with it
I found the problem, the .js and .css bundle have same response as html file for some reason. Hence, the issue in the attached ss.
I don't know the solution to that problem yet. @Leo can you help me with simply fetching /proxying my react app from s3 bucket?
In my cloudflare DNS, I have CNAME app pointing to s3 bucket url with static website enabled. And cloud is orange in CloudFlare Dns record i.e proxy is enabled.
my worker gets triggered on
nrj.life/*
So, if user visits nrj.life/tools/app
I want to serve them my react-app.
it's done!
I'll share a blog soon so that it's easier for others to implement