Skip to content

Commit

Permalink
[feat] cors 에러 해결 (그냥 proxy 로 하자...)
Browse files Browse the repository at this point in the history
  • Loading branch information
zestlee1106 committed Oct 8, 2023
1 parent 438ff9b commit 0ba2d0c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_API_HOST_DEV=http://koliving.kro.kr
NEXT_PUBLIC_API_HOST=http://koliving-backend.net
NEXT_PUBLIC_API_HOST=http://koliving.kro.kr/back-end-api
NEXTAUTH_SECRET=kolivinauthsecret0001111
NEXTAUTH_URL=http://koliving.kro.kr
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_API_HOST_DEV=http://localhost:3000
NEXT_PUBLIC_API_HOST=http://koliving-backend.net
NEXT_PUBLIC_API_HOST=http://localhost:3000/back-end-api
NEXTAUTH_URL=http://localhost:3000
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_API_HOST_DEV=http://koliving.kro.kr
NEXT_PUBLIC_API_HOST=http://koliving-backend.net
NEXT_PUBLIC_API_HOST=http://koliving.kro.kr/back-end-api
NEXTAUTH_URL=http://koliving.kro.kr
1 change: 0 additions & 1 deletion api/index-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const fetchData = async <T>(url: string, options?: RequestInit): Promise<
const data = await response.json();
return data;
} catch (error) {
console.log('%c 🤩🤩🤩 영우의 로그 : ', 'font-size: x-large; color: #bada55;', '', error);
throw new Error('Failed to fetch data');
}
};
8 changes: 8 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ const nextConfig = {
});
return modifiedConfig;
},
async rewrites() {
return [
{
source: '/back-end-api/:path*',
destination: `http://koliving-backend.net/:path*`,
},
];
},
};

module.exports = {
Expand Down
1 change: 0 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function MyApp({ Component, pageProps }: LayoutAppProps): React.ReactElement {
Authorization: `Bearer ${token}`,
},
credentials: 'include',
// mode: 'cors',
};

const response = await originalFetch(resource, config);
Expand Down
1 change: 0 additions & 1 deletion pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default NextAuth({
// eslint-disable-next-line no-param-reassign
token.user = user;
}
// console.log(token)
return token;
},
},
Expand Down

0 comments on commit 0ba2d0c

Please sign in to comment.