Skip to content

Commit

Permalink
Merge pull request #557 from Hongjw030/part3-홍재원-week19
Browse files Browse the repository at this point in the history
[홍재원] week19
  • Loading branch information
kimjngyun authored Jan 17, 2024
2 parents cd4eaf4 + 5550c9b commit 2ee9714
Show file tree
Hide file tree
Showing 131 changed files with 2,168 additions and 1,929 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/delete-merged-branch-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: delete branch on close pr

on:
pull_request:
types: [closed]

jobs:
delete-branch:
runs-on: ubuntu-latest
steps:
- name: delete branch
uses: SvanBoxel/delete-merged-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ const nextConfig = {
protocol: "http",
hostname: "localhost",
},
{
protocol: "https",
hostname: "avatars.githubusercontent.com",
},
{
protocol: "https",
hostname: "ca.slack-edge.com",
},
],
},
};
Expand Down
196 changes: 186 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
"lint": "next lint"
},
"dependencies": {
"@tanstack/react-query": "^5.17.10",
"@tanstack/react-query-devtools": "^5.17.10",
"axios": "^1.6.2",
"next": "14.0.3",
"react": "^18",
"react-cookie": "^7.0.1",
"react-dom": "^18",
"sass": "^1.69.5"
"react-hook-form": "^7.49.3",
"react-hot-toast": "^2.4.1",
"sass": "^1.69.5",
"zustand": "^4.4.7"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
Expand Down
44 changes: 44 additions & 0 deletions src/api/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import axios from "axios";
import { getCookie, setCookie } from "@/utils/manageCookie";
import { getNewToken } from "./getAuthApi";

export const axiosInstance = axios.create({
baseURL: "https://bootcamp-api.codeit.kr/api/linkbrary/v1/",
headers: {
"Content-Type": "application/json",
withCredentials: true,
},
});

axiosInstance.interceptors.request.use(
(config) => {
const accessToken = getCookie("accessToken");
config.headers["Authorization"] = `Bearer ${accessToken}`;
return config;
},
(error) => {
return Promise.reject(error);
},
);

axios.interceptors.response.use(
(res) => res,
async (error) => {
const {
config,
response: { status },
} = error;

if (status === 401) {
const originRequest = config;
const { data } = await getNewToken();
if (data) {
setCookie("accessToken", data.accessToken);
setCookie("refreshToken", data.refreshToken);
originRequest.headers["Authorization"] = `Bearer ${data.accessToken}`;
return axios(originRequest);
}
}
return Promise.reject(error);
},
);
Loading

0 comments on commit 2ee9714

Please sign in to comment.