Flask server responding with “Method Not Allowed” error for POST request to “/predict” endpoint

I have a Flask server with an endpoint “/predict” configured to handle POST requests. However, when I send a POST request to this endpoint from my frontend, the server responds with a “Method Not Allowed” error (HTTP status code 405). The frontend code is correctly sending a POST request, and CORS is configured properly. I expect the server to accept the POST request and return a response with the predicted result.

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
chatbot.js:65 Error: SyntaxError: Unexpected end of JSON input
at chatbot.js:57:22

I verified that the frontend code is sending a POST request to the correct endpoint (“/predict”).
I also confirmed that CORS is correctly configured on the Flask server.