Reactjs Axios / Spring Security Boot

I have a Java application developed using Spring Boot which is background. Front-end is an application developed by ReactJs. I use REST services. I use axios for REST calls. I recently turned on security in Spring Boot. Now it’s hard for me to confirm authentic calls.

var config = {
        auth: {
            username: 'bruker',
            password: 'passord'
        }

    };
    axios.get('http://localhost:8090/employee/all', config).then(function (response) {
        console.log(response)
    }.bind(this)).catch(function (response) {
        console.log(response)
    }.bind(this))

I get the following error: "The response to the pre-flight period is invalid (redirection)" I assume that the answer is redirected to localhost:8090/login I did not find any solutions for this. What am I doing wrong?

+4
source share
1 answer

, , "ole 2018. Axios :

    axios('/user', {
        method: 'POST',
        auth: {
            username: myUser,
            password: myPassword
        }
    }).then((response => {
        ...
    })).catch((error) => {
        ...
    })

, axios.get(... axios(.... . - axios (import axios from 'axios'), , .

, !

0

All Articles