0

I deployed a react js application to s3, and put behind AWS application load balancer. My react app is using template create by create-react-app library, build using command react-scripts build

I set the rule as if any request to /react-app* to render my application,

It is able to load index page, however, all js, and assets cannot be loaded due to ReactJS inject js script when it build as static resource,

What ReactJS build output:

<script src="/static/js/10.d87ac982.chunk.js"></script>

But I want this

<script src="/react-app/static/js/10.d87ac982.chunk.js"></script>
Vengleab SO
  • 716
  • 4
  • 11
  • 1
    Possible duplicate https://stackoverflow.com/questions/37396427/how-to-bundle-a-react-app-to-a-subdirectory-on-a-server Note that this is entirely an issue with the way you are bundling the React app. There is nothing AWS specific about the issue. – Mark B Sep 28 '21 at 17:30
  • 1
    Depends how you are bundling the project - custom, CRA, NetxJS etc, please provide more info as the question currently can't be answered – Dominic Sep 28 '21 at 17:34
  • @Dominic My react app is using template create by `create-react-app` library, build using command `react-scripts build` – Vengleab SO Sep 29 '21 at 03:42
  • @MarkB You can say it is not related, but I want to specify it as AWS due to the load balancer is serverless service which is not managed me, and I build react-js app and save to S3 as static website. And the question you mention, it is a bit different because I don't do any routing, and I don't any webpack – Vengleab SO Sep 29 '21 at 03:49
  • How is the react app being served from S3 if it is also being served through a load balancer? You can't point a load balancer at an S3 bucket. Regardless, your issue doesn't sound like anything you can fix via an AWS setting, you just need to configure your react app to be aware of the subfolder it is being served from. – Mark B Sep 29 '21 at 12:36
  • 1
    @VengleabSO check this https://stackoverflow.com/questions/49429906/how-should-i-configure-create-react-app-to-serve-app-from-subdirectory – Dominic Sep 29 '21 at 13:49
  • @MarkB, as I don't have answer, that's why I just put more clue on the question, just avoid getting any suggestion to configure on load balancer – Vengleab SO Sep 29 '21 at 15:31

0 Answers0