I am hosting my Angular 9 application in AWS using S3 and CloudFront Service. After accessing the application I am getting following error in the browser:
My index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ReachApp Success</title>
<base href="/reach">
<!-- TODo: check for common configuration for material icon -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src='https://www.google.com/recaptcha/api.js' async defer></script>
<link rel="stylesheet" href="styles.7f06624db32e037ad1c6.css"></head>
<body>
<reach-root></reach-root>
<div id="displayError"></div> <!-- Display message if IE broswer-->
<script src="runtime-es2015.0dae8cbc97194c7caed4.js" type="module"></script><script src="runtime-es5.0dae8cbc97194c7caed4.js" nomodule defer></script><script src="polyfills-es5.352c85d9e468300d10fb.js" nomodule defer></script><script src="polyfills-es2015.27bdbf82a4d61d823e83.js" type="module"></script><script src="main-es2015.89b57a9808d25011d96d.js" type="module"></script><script src="main-es5.89b57a9808d25011d96d.js" nomodule defer></script></body>
</html>
I already tried different suggestions provided by others by replacing the type="module" to type="text/javascript" but still no luck. Could anyone suggest any possible fix for this issue?
After going through all the comments the most probable cause for this issue is below
Check
redirect
tab. Make sure you redirect the error pages(403) to index.html with 200 responseMore info about BASE_HREF
--base-href If you deploy your Angular app to a subfolder, the ‘--base-href’ is important to generate the correct routes. This parameter will update the tag inside the index.html.
For example, if the index.html is on the server at /angularapp/index.html, the base href should be set to .
More information: https://angular.io/guide/deployment
ng build --prod --base-href /angularapp/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With