개발용도의 쿠키 세팅
This commit is contained in:
parent
e4455e94e5
commit
cfa46c0a6d
5
.env.dev
Normal file
5
.env.dev
Normal file
@ -0,0 +1,5 @@
|
||||
VITE_DOMAIN = http://localhost:5173/
|
||||
# VITE_LOGIN_URL = http://localhost:10325/ms/
|
||||
# VITE_FILE_URL = http://localhost:10325/ms/
|
||||
# VITE_API_URL = http://localhost:10325/api/
|
||||
VITE_API_URL = http://localhost:10325/test/
|
||||
@ -1,12 +1,12 @@
|
||||
import axios from "axios";
|
||||
import axios from 'axios';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useToastStore } from '@s/toastStore';
|
||||
|
||||
const $api = axios.create({
|
||||
baseURL: 'http://localhost:10325/api/',
|
||||
timeout: 300000,
|
||||
withCredentials : true
|
||||
})
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* Default Content-Type : json
|
||||
@ -14,7 +14,6 @@ const $api = axios.create({
|
||||
*/
|
||||
$api.interceptors.request.use(
|
||||
function (config) {
|
||||
|
||||
let contentType = 'application/json';
|
||||
|
||||
if (config.isFormData) contentType = 'multipart/form-data';
|
||||
@ -23,21 +22,21 @@ $api.interceptors.request.use(
|
||||
config.headers['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
||||
return config;
|
||||
}, function (error) {
|
||||
},
|
||||
function (error) {
|
||||
// 요청 오류가 있는 작업 수행
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 응답 인터셉터 추가하기
|
||||
$api.interceptors.response.use(
|
||||
|
||||
function (response) {
|
||||
// 2xx 범위의 응답 처리
|
||||
return response;
|
||||
},
|
||||
function (error) {
|
||||
const toastStore = useToastStore()
|
||||
const toastStore = useToastStore();
|
||||
const currentPage = error.config.headers['X-Page-Route'];
|
||||
// 오류 응답 처리
|
||||
if (error.response) {
|
||||
@ -70,7 +69,7 @@ $api.interceptors.response.use(
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default $api;
|
||||
|
||||
@ -1,14 +1,7 @@
|
||||
<template>
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<div class="col-xl-12">
|
||||
<UserFormInput
|
||||
title="아이디"
|
||||
name="id"
|
||||
:is-alert="idAlert"
|
||||
:useInputGroup="true"
|
||||
@update:data="handleIdChange"
|
||||
:value="id"
|
||||
/>
|
||||
<UserFormInput title="아이디" name="id" :is-alert="idAlert" :useInputGroup="true" @update:data="handleIdChange" :value="id" />
|
||||
|
||||
<UserFormInput
|
||||
title="비밀번호"
|
||||
@ -63,17 +56,24 @@
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
$api.post('user/login', {
|
||||
loginId: id.value,
|
||||
password: password.value,
|
||||
remember: remember.value,
|
||||
}, { headers: { 'X-Page-Route': route.path } })
|
||||
.then(res => {
|
||||
$api.post(
|
||||
'user/login',
|
||||
{
|
||||
loginId: id.value,
|
||||
password: password.value,
|
||||
remember: remember.value,
|
||||
},
|
||||
{ headers: { 'X-Page-Route': route.path } },
|
||||
).then(res => {
|
||||
if (res.status === 200) {
|
||||
// TODO: 개발용 로그인 쿠키세팅이므로 차후 삭제
|
||||
const sessionCookie = res.data.data;
|
||||
document.cookie = `JSESSIONID=${sessionCookie};path=/;expires=-1;`;
|
||||
document.cookie = `JSESSIONID=${sessionCookie};path=/`;
|
||||
|
||||
userStore.userInfo();
|
||||
router.push('/');
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user