After hosting my front and backend applications through Azure Web App, I cannot get my front end to hit an endpoint on my backend. I continuously receive a 400 Bad Request from axios.
This used to be my local endpoint:
https://localhost:7047/api/forum
Then, I switched out the root URL to what was listed as my URL under the properties section on Azure:
On my .NET app, my CORS is configured as to allow origin:
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
}));
I even went on the CORS section on Azure and set the 'Allowed Origins' to '*' as to allow access from any source to my endpoint (I'm aware this is a security concern and will change it in the future)
Based on the logs you provided, the 400 Bad Request error in the SignUp endpoint is likely due to a missing or invalid
ProfileImageFile
property in theUserDto_Creation
object.The SignUp endpoint is expecting a
multipart/form-data
request with the following properties:Username
Password
Email
ProfileImageFile
(optional)If the
ProfileImageFile
property is not present in the request, or if the file is invalid, the API will return a 400 Bad Request error.To fix the error, you need to make sure that the
ProfileImageFile
property is present in the request, and that the file is valid. You can check the validity of the file by checking theContentType
andContentLength
properties.Using below code :