- Newest
- Most votes
- Most comments
This error may be related to React application also. Would recommend to use your browser dev tools or any available React Developer Tools to debug the same. This will provide some insights where things are failing.
There is no issue in the application i have checked and also it works fine by directly accessing the instance. The link for load balancer:http://projectbalancer-1437849666.ap-south-1.elb.amazonaws.com/ You can have a look,and let me know what is causing the load balancer to show this error. Inorder to access the page you have to refresh multiple times and i have also mentioned to which server it is accessing either 1 or 2
This is an unfortunate issue with load balancers and static builds using hashed filenames.
Pre deploy you would have:
(old) index.html > fetches script-old.js
When you deploy a new build, it would have:
(new) index.html > fetches script-new.js
So during deployment, the old task can be running alongside the new task.
This is the problem; there’s no guarantee when either index.html loads, which task it will hit to retrieve the script file it needs.
The (new) index.html may hit the old task requesting script-new.js. But that doesn’t exist on the old task.
This is why you get the “Unexpected token” error. Because what’s returned is expected to be js, but ends up being html. Usually index.html is returned if a static file isn’t found, using express for example.
Hence “<“ is a “SyntaxError” for js. That’s the first character from the html file.
So, what’s the solution? There are a few, but easiest is to enable “Stickiness” on the Target Group associated with the front-end.
Similar problem / answer: https://stackoverflow.com/questions/73599420/how-to-update-react-apps-behind-an-aws-load-balancer-without-404-due-to-changing
Relevant content
- asked a year ago
- asked a year ago

The issue is most likely on the application side. Using Chrome developer tools, can you please capture the Request and Responses when the page loads and when you observe this error? This will help us better understand the issue.