Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import axios from 'axios'
- export const AXIOS = axios.create({
- baseURL: `http://localhost:8088`,
- headers: {
- 'Access-Control-Allow-Origin': 'http://localhost:8080'
- }
- })
- @Bean
- public WebMvcConfigurer corsConfigurer() { // Enables CORS globally
- return new WebMvcConfigurerAdapter() {
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/api/*").allowedOrigins("http://localhost:8080");
- }
- };
- }
- login ({commit}, authData) {
- AXIOS.post('/api/login', {
- username: authData.username,
- password: authData.password,
- withCredentials: true
- })
- .then(res => {
- console.log(res)
- commit('authUser', {
- token: res.data.idToken,
- userId: res.data.localId
- })
- })
- .catch(error => console.log(error))
- }
- curl -i -H "Content-Type: application/json" -X POST -d '{
- "username": "sysadmin",
- "password": "sysadmin"
- }' http://localhost:8088/api/login
- HTTP/1.1 200
- X-Content-Type-Options: nosniff
- X-XSS-Protection: 1; mode=block
- Cache-Control: no-cache, no-store, max-age=0, must-revalidate
- Pragma: no-cache
- Expires: 0
- X-Frame-Options: DENY
- X-Application-Context: application:8088
- authentication: <very long JWT string>
- Content-Type: application/json;charset=UTF-8
- Transfer-Encoding: chunked
Add Comment
Please, Sign In to add comment