React + .Net core api issue
Hey everyone, I need some help with an issue I'm facing after deploying my React + ASP.NET Core Web API project on an AWS EC2 Windows Server (IIS).
Project Setup (Development)
• Frontend (React):
o Works fine locally on:
https://localhost:5173/
https://192.168.1.106:5173/ (Network)
• Backend (.NET Core API):
o Works fine locally on:
https://localhost:7269/
http://localhost:5031/
• API Configuration in React (config.js):
o const API_URL = 'https://localhost:7269/api'; (Used in Axios for API calls)
Deployment Process
1. Published the project (.server) to a folder containing both frontend and backend.
2. Set up AWS EC2 (Windows Server) with IIS:
o Installed IIS, .NET Hosting Bundle, SQL Server & SSMS.
o Opened ports 80, 443, 1433 (both in Windows Firewall and AWS Security Group).
o Created a site in IIS with port 80, pointing to the published folder.
o Database Connection String (Accessible):
"DefaultConnection": "Server=51.21.196.163,1433;Database=CelestialCharm;User Id=**;Password=***;TrustServerCertificate=True;"
3. Accessing the Website
o http://51.21.196.163:80 → React site loads successfully.
o API Login/Signup endpoints work, but other API calls return 500 errors.
Issues
• API calls in the LoginController work, but all other API requests return 500 Internal Server Error.
• The issue does not occur in development; only happens after deployment.
What I’ve Tried
• Checked that the backend is running on IIS.
• Ensured database is accessible from the server.
• Opened necessary firewall and security group ports.
Questions
• What could be causing API calls to fail with a 500 error only after deployment?
• How can I debug this in IIS or ASP.NET Core logs?
• Is there something I need to configure in IIS for proper API routing?
Project Setup (Development)
• Frontend (React):
o Works fine locally on:
https://localhost:5173/
https://192.168.1.106:5173/ (Network)
• Backend (.NET Core API):
o Works fine locally on:
https://localhost:7269/
http://localhost:5031/
• API Configuration in React (config.js):
o const API_URL = 'https://localhost:7269/api'; (Used in Axios for API calls)
Deployment Process
1. Published the project (.server) to a folder containing both frontend and backend.
2. Set up AWS EC2 (Windows Server) with IIS:
o Installed IIS, .NET Hosting Bundle, SQL Server & SSMS.
o Opened ports 80, 443, 1433 (both in Windows Firewall and AWS Security Group).
o Created a site in IIS with port 80, pointing to the published folder.
o Database Connection String (Accessible):
"DefaultConnection": "Server=51.21.196.163,1433;Database=CelestialCharm;User Id=**;Password=***;TrustServerCertificate=True;"
3. Accessing the Website
o http://51.21.196.163:80 → React site loads successfully.
o API Login/Signup endpoints work, but other API calls return 500 errors.
Issues
• API calls in the LoginController work, but all other API requests return 500 Internal Server Error.
• The issue does not occur in development; only happens after deployment.
What I’ve Tried
• Checked that the backend is running on IIS.
• Ensured database is accessible from the server.
• Opened necessary firewall and security group ports.
Questions
• What could be causing API calls to fail with a 500 error only after deployment?
• How can I debug this in IIS or ASP.NET Core logs?
• Is there something I need to configure in IIS for proper API routing?
