Guest User

Untitled

a guest
Nov 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import axios from 'axios'
  2.  
  3. export const AXIOS = axios.create({
  4. baseURL: `http://localhost:8088`,
  5. headers: {
  6. 'Access-Control-Allow-Origin': 'http://localhost:8080'
  7. }
  8. })
  9.  
  10. @Bean
  11. public WebMvcConfigurer corsConfigurer() { // Enables CORS globally
  12. return new WebMvcConfigurerAdapter() {
  13. @Override
  14. public void addCorsMappings(CorsRegistry registry) {
  15. registry.addMapping("/api/*").allowedOrigins("http://localhost:8080");
  16. }
  17. };
  18. }
  19.  
  20. login ({commit}, authData) {
  21. AXIOS.post('/api/login', {
  22. username: authData.username,
  23. password: authData.password,
  24. withCredentials: true
  25. })
  26. .then(res => {
  27. console.log(res)
  28. commit('authUser', {
  29. token: res.data.idToken,
  30. userId: res.data.localId
  31. })
  32. })
  33. .catch(error => console.log(error))
  34. }
  35.  
  36. curl -i -H "Content-Type: application/json" -X POST -d '{
  37. "username": "sysadmin",
  38. "password": "sysadmin"
  39. }' http://localhost:8088/api/login
  40.  
  41. HTTP/1.1 200
  42. X-Content-Type-Options: nosniff
  43. X-XSS-Protection: 1; mode=block
  44. Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  45. Pragma: no-cache
  46. Expires: 0
  47. X-Frame-Options: DENY
  48. X-Application-Context: application:8088
  49. authentication: <very long JWT string>
  50. Content-Type: application/json;charset=UTF-8
  51. Transfer-Encoding: chunked
Add Comment
Please, Sign In to add comment