When integrating Azure Front Door with an AWS-hosted Single Page Application (SPA) on S3 + CloudFront, developers often encounter MIME type errors. A common issue is that scripts and stylesheets fail to load due to incorrect MIME types, leading to errors such as:
“Expected a JavaScript module script but the server responded with a MIME type of ‘text/html’.”
This typically happens due to misconfigurations in CloudFront, S3 bucket settings, or response headers. In this post, we’ll explore the root cause of these errors and how to properly configure your setup to ensure smooth redirection and loading of static assets.

The error is occuring is due to Azure Front Door incorrectly serving your AWS S3/CloudFront-hosted Single Page Application (SPA). The MIME type mismatch suggests that the frontend resources (JS, CSS) are being served as text/html
instead of their correct content types. This is often caused by misconfigurations in Azure Front Door, S3, or CloudFront.
✅ Solutions
1. Ensure Proper MIME Types in S3
Your AWS S3 bucket must serve files with the correct MIME types.
- Open AWS S3 Console → Select your Bucket → Properties → Scroll to “Static website hosting.”
- Check the metadata of the files:
- JavaScript files should have
Content-Type: application/javascript
- CSS files should have
Content-Type: text/css
- JavaScript files should have
- If incorrect, update them:
- Go to Objects → Select a file → Properties → Under “Metadata,” add the correct Content-Type.
Command to Fix for All Files
If you want to correct MIME types for all files at once, run this command: