Skip to content

Commit

Permalink
Merge pull request #41 from SproutMJ/develop
Browse files Browse the repository at this point in the history
master<-develop
  • Loading branch information
SproutMJ authored May 26, 2024
2 parents 27c368a + bf3f159 commit 7d75ecd
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 43 deletions.
8 changes: 4 additions & 4 deletions backend/src/main/java/hello/aimju/login/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public void addInterceptors(InterceptorRegistry registry) {

@Override
public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**") // 모든 요청에 대해 CORS 허용
// .allowedOrigins("*") // 모든 Origin(도메인) 허용. 실제 운영 환경에서는 특정 Origin으로 제한할 것을 권장
// .allowedMethods("*") // 모든 HTTP 메서드 허용 (GET, POST, PUT, DELETE 등)
// .allowedHeaders("*"); // 모든 요청 헤더 허용
registry.addMapping("/**") // 모든 요청에 대해 CORS 허용
.allowedOrigins("*") // 모든 Origin(도메인) 허용. 실제 운영 환경에서는 특정 Origin으로 제한할 것을 권장
.allowedMethods("*") // 모든 HTTP 메서드 허용 (GET, POST, PUT, DELETE 등)
.allowedHeaders("*"); // 모든 요청 헤더 허용
}
}
8 changes: 0 additions & 8 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
return [
{
source: "/api/:path*",
destination: process.env.NEXT_PUBLIC_API_BASE_URL + "/api/:path*",
},
];
},
};

export default nextConfig;
12 changes: 6 additions & 6 deletions frontend/src/app/boards/[boardId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export default function BoardDetail({params}: {params: {boardId: string}}) {
const router = useRouter();

const fetchComment = useCallback(async () => {
const response = await axios.get(`/api/comments/${params.boardId}`);
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/comments/${params.boardId}`);
setComments(response.data.map((c: Comment) => (c)));
}, [params.boardId]);

useEffect(() => {
const fetchBoard = async () => {
const response = await axios.get(`/api/boards/${params.boardId}`);
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards/${params.boardId}`);
setTitle(response.data.title);
setContent(response.data.content);
setCreatedTime(response.data.createdTime);
Expand All @@ -71,7 +71,7 @@ export default function BoardDetail({params}: {params: {boardId: string}}) {
boardId: boardId,
content: comment,
}
const response = await axios.post('/api/comments', commentDto);
const response = await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/comments`, commentDto);
setComment('');
await fetchComment();
}
Expand All @@ -87,7 +87,7 @@ export default function BoardDetail({params}: {params: {boardId: string}}) {
content: modifyComment,
}

const response = await axios.patch('/api/comments', commentDto);
const response = await axios.patch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/comments`, commentDto);
await fetchComment();
restoreModifyComment();
}
Expand All @@ -97,12 +97,12 @@ export default function BoardDetail({params}: {params: {boardId: string}}) {
}

const handleDeleteComment = async (id: number) => {
const response = await axios.delete(`/api/comments/${id}`);
const response = await axios.delete(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/comments/${id}`);
await fetchComment();
}

const handleDeleteBoard = async () => {
const response = await axios.delete(`/api/boards/${boardId}`);
const response = await axios.delete(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards/${boardId}`);
await router.push('/boards');
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/boards/modify/[boardId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function BoardWriting({params}: {params: {boardId: string}}) {

useEffect(()=>{
const fetchBoard = async ()=> {
const response = await axios.get(`/api/boards/${params.boardId}`);
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards/${params.boardId}`);
setTitle(response.data.title);
setContent(response.data.content);
};
Expand All @@ -43,7 +43,7 @@ export default function BoardWriting({params}: {params: {boardId: string}}) {

const handleBoardModify = async ()=>{
try {
const response = await axios.put('/api/boards', {
const response = await axios.put(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards`, {
id: params.boardId,
title: title,
content: content,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/boards/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export default function Board() {
try {
let response;
if(searchKeyword === null){
response = await axios.get('/api/boards', {
response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards`, {
params: {
page: page,
}
});
}else{
response = await axios.get('/api/boards', {
response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/boards`, {
params: {
page: page,
searchKeyword: searchKeyword
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/chatroom/[chatroomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function ChatRoom({ params }: { params: { chatroomId: number } })
recipe: recipe,
};
try {
const response = await axios.post('/api/recipe/save-chat', chatRecipeRequestDto);
const response = await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recipe/save-chat`, chatRecipeRequestDto);
console.log('Recipe saved successfully:', response.data);
handleRoutingScrap();
} catch (error) {
Expand All @@ -43,7 +43,7 @@ export default function ChatRoom({ params }: { params: { chatroomId: number } })


useEffect(() => {
axios.get<Message[]>(`/api/chatroom/${params.chatroomId}`)
axios.get<Message[]>(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/chatroom/${params.chatroomId}`)
.then(response => {
const messagesWithBr = response.data.map(message => ({
...message,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function Login() {

const handleLogin = async () => {
try {
const response = await fetch('/api/login', {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function Main() {
useEffect(() => {
const fetchChatRooms = async () => {
try {
const response = await axios.get("/api/chatrooms");
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/chatrooms`);
setChatRooms(response.data);
} catch (error) {
console.error("Error fetching chat rooms:", error);
Expand All @@ -58,7 +58,7 @@ export default function Main() {

const handleDeleteClick = async (chatId: number) => {
try {
await axios.delete(`/api/chatroom/${chatId}`);
await axios.delete(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/chatroom/${chatId}`);
setChatRooms(chatRooms.filter(chat => chat.chatId !== chatId));
} catch (error) {
console.error("Error deleting chat room:", error);
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/app/recommend/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function Recommend() {
setIsLoading(true); // 로딩 시작
console.log(middleIngredients)
try {
const response = await axios.post('/api/recommendation-menu', middleIngredients);
const response = await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recommendation-menu`, middleIngredients);
const data = response.data;
setMenus(data);
handleNextStep();
Expand All @@ -84,7 +84,7 @@ export default function Recommend() {
recipe: recipeString,
};
try {
const response = await axios.post('/api/recipe/save-chat', chatRecipeRequestDto);
const response = await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recipe/save-chat`, chatRecipeRequestDto);
console.log('Recipe saved successfully:', response.data);
handleRoutingScrap();
} catch (error) {
Expand All @@ -100,7 +100,7 @@ export default function Recommend() {
ingredients: middleIngredients.split(', '),
};
try {
const response = await axios.post('/api/recommendation-recipe-str', request);
const response = await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recommendation-recipe-str`, request);
setRecipeString(response.data);
const newRecipeLink = `https://www.10000recipe.com/recipe/list.html?q=${encodeURIComponent(menu)}`;
setRecipeLink(newRecipeLink);
Expand Down Expand Up @@ -164,7 +164,7 @@ export default function Recommend() {
};
console.log(chatRoomRequestDto);

axios.post('/api/recommendation-save', chatRoomRequestDto)
axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recommendation-save`, chatRoomRequestDto)
.then(response => {
console.log('Chat data saved successfully:', response.data);
})
Expand All @@ -190,7 +190,7 @@ export default function Recommend() {

try {
setIsLoading(true);
const response = await fetch('/api/photo-recognition', {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/photo-recognition`, {
method: 'POST',
body: formData,
});
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/scrap/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Scrap() {
const handleLogout = async () => {
try {
// 로그아웃 요청 보내기
await axios.post('/api/logout');
await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/logout`);
// 로그아웃 후 로그인 페이지로 이동
router.push('/login');
} catch (error) {
Expand All @@ -62,7 +62,7 @@ export default function Scrap() {
useEffect(() => {
const fetchRecipes = async () => {
try {
const response = await axios.get("/api/recipes");
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recipes`);
setRecipes(response.data);
} catch (error) {
console.error("Error fetching recipes:", error);
Expand All @@ -74,7 +74,7 @@ export default function Scrap() {

const handleLearnMoreClick = async (recipeId: number) => {
try {
const response = await axios.get(`/api/recipe/${recipeId}`);
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recipe/${recipeId}`);
const recipeDetails: RecipeDetail = response.data;

setSelectedRecipe({
Expand All @@ -90,7 +90,7 @@ export default function Scrap() {
const handleDeleteClick = async () => {
if (recipeToDelete !== null) {
try {
await axios.delete(`/api/recipe/${recipeToDelete}`);
await axios.delete(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/recipe/${recipeToDelete}`);
setRecipes(recipes.filter(recipe => recipe.recipeId !== recipeToDelete));
closeModal();
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function SignUp() {

async function signUp() {
const userName = id;
const res = await fetch('/api/signup',{
const res = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/signup`,{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/user/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function UserPage() {
newUserName
};
try {
const response = await axios.put('/api/user/change-userName', data);
const response = await axios.put(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/user/change-userName`, data);
if (response.data && response.data.statuscode === 200) {
setChangeUserNameModalOpen(false);
setUserDetail(prevDetail => (prevDetail ? { ...prevDetail, userName: newUserName } : null));
Expand All @@ -88,7 +88,7 @@ export default function UserPage() {
newPassword
};
try {
const response = await axios.put('/api/user/change-password', data);
const response = await axios.put(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/user/change-password`, data);
if (response.data && response.data.statuscode === 200) {
setChangePasswordModalOpen(false);
window.alert(response.data.msg); // 성공 메시지 표시
Expand All @@ -114,7 +114,7 @@ export default function UserPage() {
};

try {
const response = await axios.delete('/api/user', { data });
const response = await axios.delete(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/user`, { data });
if (response.data && response.data.statuscode === 200) {
setChangeUserNameModalOpen(false);
window.alert(response.data.msg); // 성공 메시지 표시
Expand All @@ -131,7 +131,7 @@ export default function UserPage() {
useEffect(() => {
const fetchUserDetail = async () => {
try {
const response = await axios.get('/api/user-detail');
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/user-detail`);
setUserDetail(response.data);
} catch (error) {
console.error('Error fetching user details:', error);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/ui/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const Header = () => {
useEffect(()=> {
const fetchUser = async ()=> {
try {
const response = await axios.get('/api/current-user');
const response = await axios.get(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/current-user`);
setUser(response.data);
}catch (e: any){
if(e.response.status === 401){
Expand All @@ -30,7 +30,7 @@ export const Header = () => {

const handleLogout = async () => {
try {
await axios.post('/api/logout');
await axios.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/logout`);
clearUser();
router.push('/login');
} catch (error) {
Expand Down

0 comments on commit 7d75ecd

Please sign in to comment.