I make a server call using fetch API except one post request all another post/get request hit on the exactly/desire server URL, but the one post requests hit on the localhost server.
service class code and base URL for the post request is the same as others.
service.js:56 POST http://localhost:3000/.... 500 (Internal Server Error)
Code:
function save(workflow) {
const token = authenticationGenerator.generateAuthenticationToken(localStorage.getItem('username'),
localStorage.getItem('password'));
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': token },
body: JSON.stringify(workflow)
};
return fetch('/workflow', requestOptions)
.then(handleResponse).then(workflowData => {
return workflowData;
});
}
... hit on localhost ...
function save(phase) {
const token = authenticationGenerator.generateAuthenticationToken(localStorage.getItem('username'),
localStorage.getItem('password'));
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': token },
body: JSON.stringify(phase)
};
return fetch('/phases', requestOptions)
.then(handleResponse).then(phaseData => {
return phaseData;
});
}
...package.json ...
"scripts": {
"start": "react-scripts start",
"build": "webpack --mode production",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://url../v1",
"eslintConfig": {
"extends": "react-app"
},