Skip to content

Commit

Permalink
server side시 x-forwarded-for 등록
Browse files Browse the repository at this point in the history
server side시 x-forwarded-for 등록
  • Loading branch information
seoko97 authored Dec 5, 2023
2 parents 11f1fcf + 1cfb762 commit d20c29a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
8 changes: 0 additions & 8 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
---
name: issue_template
about: Suggest an idea for this project
title: ""
labels: ""
assignees: ""
---

## :briefcase: **구현 개요**

## :white_check_mark: **진행 계획 및 현황**
Expand Down
10 changes: 1 addition & 9 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
---
name: pull_request_template
about: PR에 대한 상세내용
title: ''
labels: ''
assignees: ''
---

- Closes #이슈번호
- Closes #이슈번호

## **구현 기능 명세**

Expand Down
12 changes: 12 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ const getToken = async (tokeName: string) => {
}
};

const setForwardedForByServer = async (config: AxiosRequestConfig) => {
if (!isServer || !config.headers) return;

config.headers["x-forwarded-for"] = (await import("next/headers"))
.headers()
.get("x-forwarded-for");

config.headers["x-real-ip"] = (await import("next/headers")).headers().get("x-real-ip");
};

api.interceptors.request.use(async (config) => {
const token = await getToken("access-token");

if (token) config.headers.setAuthorization(`Bearer ${token}`);

await setForwardedForByServer(config);

return config;
});

Expand Down

0 comments on commit d20c29a

Please sign in to comment.