Last active
September 18, 2017 06:38
-
-
Save ruddell/da2a3c58cebb55256dd7e8111a258389 to your computer and use it in GitHub Desktop.
csrf + cors issue reproduction, source https://stackoverflow.com/questions/46062892/jhipster-cors-fails-on-form-login-actual-request-not-pre-flight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.2/axios.js"></script> | |
<script type="text/javascript"> | |
var Http = axios.create({ | |
baseURL: 'http://localhost:8080/api', | |
}); | |
Http.interceptors.request.use(function (config) { | |
config.xsrfCookieName = 'CSRF-TOKEN'; | |
config.xsrfHeaderName = 'X-CSRF-TOKEN'; | |
config.withCredentials = true; | |
return config; | |
}); | |
var credentials = { | |
username: 'user', | |
password: 'user', | |
rememberMe: true | |
}; | |
Http.post('authentication', 'j_username=' + credentials.username + | |
'&j_password=' + credentials.password + | |
'&remember-me=' + credentials.rememberMe + | |
'&submit=Login'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment