import React, { Component } from "react";
import axios from 'axios';
class App extends Component {
handleSubmit(event) {
axios.post('http://localhost:3050/login', {
"username": "username",
"password": "password"
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
event.preventDefault();
}
render() {
return(
<form onSubmit={this.handleSubmit}>
<input type="submit" value="Submit" />
</form>
);
}
}
export default App;
Simply just checks the backend with json of username set to "username" and password set to "password"
My backend is spring boot and using the end link /login with "username" and "Password" should give some response. So this code works except CORS blocks the connection so its stuck on processing forever. A solution I found was disabling all security in chrome and it works. But I'm looking for a permanent solution without having to disable security on chrome settings. Not sure if I do it through springboot or react