Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ jobs:
- name: Copy JAR to EC2
run: |
scp -o StrictHostKeyChecking=no -i pirocheck.pem backend/pirocheck/build/libs/*.jar ubuntu@${{ secrets.EC2_HOST }}:/home/ubuntu/

- name: Run jar on EC2
run: |
ssh -o StrictHostKeyChecking=no -i pirocheck.pem \
ubuntu@${{ secrets.EC2_HOST }} \
"fuser -k 8080/tcp || true && nohup java -jar pirocheck-0.0.1-SNAPSHOT.jar > log.txt 2>&1 &"


- name: Restart Spring Boot on EC2
run: |
ssh -o StrictHostKeyChecking=no -i pirocheck.pem ubuntu@${{ secrets.EC2_HOST }} 'bash ~/restart.sh'
Expand Down Expand Up @@ -106,4 +113,4 @@ jobs:
AWS_S3_BUCKET: www.pirocheck.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: frontend/dist
SOURCE_DIR: frontend/dist
7 changes: 3 additions & 4 deletions frontend/src/Deposit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Header from "./components/Header";
import styles from "./Deposit.module.css";
import axios from "axios";
import { useEffect, useState } from "react";
import api from "./api/api";

const Deposit = () => {
const [deposit, setDeposit] = useState(null);
Expand All @@ -12,10 +13,8 @@ const Deposit = () => {

if (!userId) return;

axios
.get(`/api/deposit/${userId}`, {
withCredentials: true, // 세션 쿠키 포함
})
api
.get(`/deposit/${userId}`)
.then((res) => setDeposit(res.data))
.catch((err) => {
alert("보증금 정보를 불러오지 못했습니다.");
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/api/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios from "axios";

const api = axios.create({
baseURL: "/api",
withCredentials: true,
});

// 401 오류 시 로그인 페이지로 리다이렉트
api.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
window.location.href = "/login";
}
return Promise.reject(error);
}
);

export default api;