diff --git a/frontend/next.config.js b/frontend/next.config.js index b6cefa30..9e34424a 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -4,15 +4,15 @@ const nextConfig = { unoptimized: true, domains: ["hanroro-fanpage.s3.ap-northeast-2.amazonaws.com"], }, - // async rewrites() { - // return [ - // { - // source: "/api/:path*", - // destination: process.env.NEXT_PUBLIC_BASE_URL + "/:path*", - // }, - // ]; - // }, - output: "export", + async rewrites() { + return [ + { + source: "/api/:path*", + destination: process.env.NEXT_PUBLIC_BASE_URL + "/:path*", + }, + ]; + }, + // output: "export", trailingSlash: true, reactStrictMode: false, }; diff --git a/frontend/package.json b/frontend/package.json index df31d4c5..6b9e11bf 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,7 +5,7 @@ "packageManager": "yarn@4.0.2", "scripts": { "dev": "NODE_ENV=development next dev", - "build": "next build && next export", + "build": "next build", "start": "next start", "lint": "next lint", "prepare": "cd .. && husky install frontend/.husky", diff --git a/frontend/src/apis/admin/index.ts b/frontend/src/apis/admin/index.ts index 545f95f7..c0ec32ad 100644 --- a/frontend/src/apis/admin/index.ts +++ b/frontend/src/apis/admin/index.ts @@ -4,7 +4,7 @@ import { defaultApi } from "@/apis"; export const checkAdmin = async (accessToken: string) => { try { - const { data } = await defaultApi.get("/admin", { + const { data } = await defaultApi.get("/api/admin", { headers: { Authorization: `Bearer ${accessToken}` }, }); return data; @@ -22,7 +22,7 @@ export const getReportedPosts = async ({ accessToken?: string; }) => { const api = defaultApi - .get(`/admin/post/${pageParam}`, { + .get(`/api/admin/post/${pageParam}`, { headers: { Authorization: `Bearer ${accessToken}` }, }) .then(async (data) => { @@ -44,7 +44,7 @@ export const getReportedComments = async ({ accessToken?: string; }) => { const api = defaultApi - .get(`/admin/comment/${pageParam}`, { + .get(`/api/admin/comment/${pageParam}`, { headers: { Authorization: `Bearer ${accessToken}` }, }) .then(async (data) => { diff --git a/frontend/src/apis/auth/index.ts b/frontend/src/apis/auth/index.ts index d5972fd7..12f032f3 100644 --- a/frontend/src/apis/auth/index.ts +++ b/frontend/src/apis/auth/index.ts @@ -2,27 +2,27 @@ import { defaultApi } from "@/apis/index"; import { ClientData, ValidateAccessToken } from "@/types/user"; export const refreshAccessTokenApi = async (oAuthType: string): Promise => { - const { data } = await defaultApi.post(`/auth/${oAuthType}/refresh`); + const { data } = await defaultApi.post(`/api/auth/${oAuthType}/refresh`); return data; }; export const logoutApi = async (accessToken: string, id: string) => { const userData = { accessToken, id }; - const api = await defaultApi.post("/auth/kakao/logout", userData, { + const api = await defaultApi.post("/api/auth/kakao/logout", userData, { headers: { "Content-Type": "application/json" }, }); return api; }; export const loginApi = async (search: string): Promise => { - const { data } = await defaultApi.get(`/auth/kakao/login?code=${search}`); + const { data } = await defaultApi.get(`/api/auth/kakao/login?code=${search}`); return data; }; export const validateAccessTokenApi = async ( accessToken: string, ): Promise => { - const { data } = await defaultApi.post("/auth/kakao/validate", { + const { data } = await defaultApi.post("/api/auth/kakao/validate", { accessToken, }); return data; diff --git a/frontend/src/apis/post/index.ts b/frontend/src/apis/post/index.ts index f2be6e99..af216d5c 100644 --- a/frontend/src/apis/post/index.ts +++ b/frontend/src/apis/post/index.ts @@ -11,7 +11,7 @@ export const getBoardPosts = async ({ accessToken?: string; }) => { const api = defaultApi - .get(`/post/page/${pageParam}`, { + .get(`/api/post/page/${pageParam}`, { headers: { Authorization: `Bearer ${accessToken}` }, }) .then(async (data) => { @@ -38,7 +38,7 @@ export const uploadBoardPost = async ({ // formData.append(key, value); // }); // console.log(formData); - const api = await defaultApi.post("/post", data, { + const api = await defaultApi.post("/api/post", data, { headers: { Authorization: `Bearer ${accessToken}` }, }); @@ -46,7 +46,7 @@ export const uploadBoardPost = async ({ }; export const getRecentPosts = async (accessToken: string): Promise => { - const { data } = await defaultApi.get(`/post/recent`, { + const { data } = await defaultApi.get(`/api/post/recent`, { headers: { Authorization: `Bearer ${accessToken}` }, }); try { @@ -67,7 +67,7 @@ export const getUserPosts = async ({ userId: string; }) => { try { - const { data } = await defaultApi.get(`/post/user/${userId}?page=${pageParam}`, { + const { data } = await defaultApi.get(`/api/post/user/${userId}?page=${pageParam}`, { headers: { Authorization: `Bearer ${accessToken}` }, }); return { pages: data, pageParams: pageParam + 1 }; @@ -86,7 +86,7 @@ export const getLikedPosts = async ({ accessToken?: string; }) => { try { - const { data } = await defaultApi.get(`/post/like?page=${pageParam}`, { + const { data } = await defaultApi.get(`/api/post/like?page=${pageParam}`, { headers: { Authorization: `Bearer ${accessToken}` }, }); return { pages: data, pageParams: pageParam + 1 }; @@ -98,7 +98,7 @@ export const getLikedPosts = async ({ export const dislikePost = async ({ _id, accessToken }: { _id: string; accessToken: string }) => { const api = await defaultApi - .post("/post/dislike", { _id }, { headers: { Authorization: `Bearer ${accessToken}` } }) + .post("/api/post/dislike", { _id }, { headers: { Authorization: `Bearer ${accessToken}` } }) .then() .catch((err) => { console.log(err); @@ -109,7 +109,7 @@ export const dislikePost = async ({ _id, accessToken }: { _id: string; accessTok export const likePost = async ({ _id, accessToken }: { _id: string; accessToken: string }) => { const api = await defaultApi - .post("/post/like", { _id }, { headers: { Authorization: `Bearer ${accessToken}` } }) + .post("/api/post/like", { _id }, { headers: { Authorization: `Bearer ${accessToken}` } }) .then() .catch((err) => { console.log(err); @@ -129,7 +129,7 @@ export const addComment = async ({ }) => { try { await defaultApi.post( - "/post/comment", + "/api/post/comment", { postId, content }, { headers: { Authorization: `Bearer ${accessToken}` } }, ); @@ -147,7 +147,7 @@ export const deletePost = async ({ accessToken: string; }) => { try { - await defaultApi.delete(`/post`, { + await defaultApi.delete(`/api/post`, { data: { postId }, headers: { Authorization: `Bearer ${accessToken}` }, }); @@ -165,7 +165,7 @@ export const deleteComment = async ({ accessToken: string; }) => { try { - await defaultApi.delete(`/post/comment`, { + await defaultApi.delete(`/api/post/comment`, { data: { commentId }, headers: { Authorization: `Bearer ${accessToken}` }, }); @@ -191,7 +191,7 @@ export const editPost = async ({ // }); const newData = { ...data, postId }; try { - const api = await defaultApi.patch(`/post`, newData, { + const api = await defaultApi.patch(`/api/post`, newData, { headers: { Authorization: `Bearer ${accessToken}` }, }); return api; @@ -210,7 +210,7 @@ export const reportPost = async ({ }) => { try { await defaultApi.post( - "/post/report", + "/api/post/report", { postId }, { headers: { Authorization: `Bearer ${accessToken}` } }, ); @@ -229,7 +229,7 @@ export const reportComment = async ({ }) => { try { await defaultApi.post( - "/post/comment/report", + "/api/post/comment/report", { commentId }, { headers: { Authorization: `Bearer ${accessToken}` } }, ); diff --git a/frontend/src/apis/user/index.ts b/frontend/src/apis/user/index.ts index b772c4f2..4a631ee7 100644 --- a/frontend/src/apis/user/index.ts +++ b/frontend/src/apis/user/index.ts @@ -2,7 +2,7 @@ import { defaultApi } from "@/apis/index"; import { UserData, UserEditProfileType } from "@/types/user"; export const getMyProfileInfo = async (accessToken: string): Promise => { - const { data } = await defaultApi.post("/user/profile", { + const { data } = await defaultApi.post("/api/user/profile", { accessToken: accessToken, }); return data; @@ -15,13 +15,13 @@ export const editProfile = async (data: UserEditProfileType) => { formData.append(key, value); }); - const api = await defaultApi.post(`/user/profile/edit`, formData, { + const api = await defaultApi.post(`/api/user/profile/edit`, formData, { headers: { Authorization: `Bearer ${accessToken}` }, }); return api; }; export const searchProfile = async (_id: string) => { - const { data } = await defaultApi.get(`/user/profile/${_id}`); + const { data } = await defaultApi.get(`/api/user/profile/${_id}`); return data; };