I am using the Fetch Api to send data from the frontend to backend and I am not saving any data into a database. When I ran my project locally, all the Fetch calls worked perfectly fine but now that I have deployed I am getting a Server error 500 whenever a POST request is being made.
In my server log, I have print statements that run in the backend and I can see those print statements being printed in the error log implying that this does reach the backend. I can also see that the correct data is being passed to the backend. However I am still getting a POST 500 (internal server error)
This is the code for my fetch call:
const data = new FormData();
data.append('image', files[0])
fetch('/api/itot/', {
method: 'POST',
body:data
})
.then(response => response.json())
.then(data => changeCurrent(data["text"]))
The above is for an image file as input.
Here is another fetch call with only passing to the backend text and recieving a modified version of that text back:
const data = {text: currentText};
fetch('/api/input/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => props.changeText(data["text"]))
.then(() => props.changeLoadingStatus(false))
In both examples, data["text"] would be what I would want to display with the frontend.
I can also include the error log or server log if needed.
Thanks for any insight.