Skip to content

Commit

Permalink
Merge pull request #101 from prgrms-web-devcourse-final-project/hotfix
Browse files Browse the repository at this point in the history
fix: νšŒμ›κ°€μž…
  • Loading branch information
aaahyesu authored Dec 5, 2024
2 parents 8199a0d + 061d126 commit a4488a0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
17 changes: 7 additions & 10 deletions app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,13 @@ const Signup = () => {
setIsSubmitting(true);

try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/user-service/users`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
}
);
const response = await fetch('/api/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
});

if (response.ok) {
setNickname(formData.nickname);
Expand Down
26 changes: 26 additions & 0 deletions app/api/nickname/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NextRequest, NextResponse } from 'next/server';
import { API_URL_CONFIG, API_BASE_URL } from '@/config/apiEndPointConfig';
import axiosInstance from '@/lib/axios';

export async function POST(request: NextRequest) {
try {
const data = await request.json();

const response = await axiosInstance.post(
`${API_BASE_URL.DNS}${API_URL_CONFIG.AUTH.NICKNAME}`,
data,
{
headers: {
'Content-Type': 'application/json',
},
}
);
return NextResponse.json(response.data);
} catch (error) {
console.error('Nickname check error:', error);
return NextResponse.json(
{ error: 'Failed to check nickname' },
{ status: 500 }
);
}
}
6 changes: 3 additions & 3 deletions app/api/signup/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API_PORT_CONFIG, API_URL_CONFIG } from '@/config/apiEndPointConfig';
import { API_URL_CONFIG, API_BASE_URL } from '@/config/apiEndPointConfig';
import axiosInstance from '@/lib/axios';
import { NextRequest, NextResponse } from 'next/server';

Expand All @@ -7,15 +7,15 @@ export async function POST(request: NextRequest) {

try {
const res = await axiosInstance.post(
`${axiosInstance.defaults.baseURL}:${API_PORT_CONFIG.AUTH}${API_URL_CONFIG.AUTH.SIGNUP}`,
`${API_BASE_URL.DNS}${API_URL_CONFIG.AUTH.SIGNUP}`,
data,
{
headers: {
'Content-Type': 'application/json',
},
}
);
return NextResponse.json(res);
return NextResponse.json(res.data);
} catch (error) {
console.error(error);
return NextResponse.json(
Expand Down
21 changes: 9 additions & 12 deletions components/Layout/Signup/NickNameInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@ const NickNameInput = ({ onNicknameValidated }: NickNameInputProps) => {
}

try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/user-service/nickname`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ nickname }),
}
);
const response = await fetch('/api/nickname', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ nickname }),
});

const result = await response.text();
const result = await response.json();

if (response.ok) {
if (result === 'PERMIT') {
Expand Down Expand Up @@ -73,7 +70,7 @@ const NickNameInput = ({ onNicknameValidated }: NickNameInputProps) => {
const handleInputChange = (value: string) => {
setNickname(value);
setValidationMessage(null);
onNicknameValidated(value, false); // μž…λ ₯값이 λ³€κ²½λ˜λ©΄ μœ νš¨μ„± μ΄ˆκΈ°ν™”
onNicknameValidated(value, false);
};

return (
Expand Down
3 changes: 2 additions & 1 deletion config/apiEndPointConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export const API_URL_CONFIG = Object.freeze({
POST_SINGLE: '/api/content-service/contents/',
},
AUTH: {
SIGNUP: '/api/auth/user-service/users',
SIGNUP: '/api/user-service/users',
LOGIN: '/api/user-service/login',
NICKNAME: '/api/user-service/nickname',
},
NOTIFICATION: {
SSE: '/api/notification-service/sse/connect/',
Expand Down

0 comments on commit a4488a0

Please sign in to comment.