5.5 Frontend with S3 & CloudFront
Frontend Hosting with S3 & CloudFront
This section covers how to build and deploy the React frontend from the frontend/ folder
using Amazon S3 and Amazon CloudFront.
Frontend architecture diagrams


These diagrams illustrate how users access the React app via CloudFront, which serves content from the S3 bucket.
Frontend Capabilities
The React app provides UI flows for:
- User login and role-based navigation (Admin / Manager / Line Leader).
- Managing production orders and viewing order details.
- Viewing production plans, line schedules, and basic dashboards.
- Accessing AI insights pages (via
aiService) for production summaries and analysis.
Building the Frontend
- Install dependencies locally:
- Configure API base URL (e.g., using environment variables like
VITE_API_BASE_URL). - Build the production bundle:
- Verify that a
dist/ directory (or similar) is produced with static files.
Hosting on Amazon S3
- Create an S3 bucket dedicated to hosting the frontend (e.g.,
ims-frontend-prod). - Enable static website hosting (or use CloudFront origin access control for private buckets).
- Upload the contents of the
dist/ folder to the S3 bucket. - Configure the index document (e.g.,
index.html) and error document for SPA routing.
Distributing via CloudFront
- Create a CloudFront distribution with the S3 bucket as origin.
- Set the default root object to
index.html. - Configure caching and optional custom error responses for SPA (serving
index.html on 404). - Associate an ACM certificate and custom domain (via Route 53) if using HTTPS.
API Integration & CORS
- Ensure the frontend calls the backend API via the correct base URL (ALB DNS or custom domain).
- Configure CORS on the backend (and/or ALB) so that the CloudFront domain is allowed.
- For production, avoid hard-coding URLs; use environment variables during build.
By the end of this section, the React frontend will be accessible via a CloudFront URL or your custom domain,
serving as the main entrypoint to the IMS system.