-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from prgrms-web-devcourse-final-project/hotfix
feat: http error
- Loading branch information
Showing
2 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { API_BASE_URL } from '@/config/apiEndPointConfig'; | ||
import axiosInstance from '@/lib/axios'; | ||
|
||
export async function GET(request: NextRequest) { | ||
try { | ||
// URLμμ κ²μμ΄ νλΌλ―Έν° μΆμΆ | ||
const { searchParams } = new URL(request.url); | ||
const queryString = searchParams.get('string'); | ||
|
||
if (!queryString) { | ||
return NextResponse.json( | ||
{ error: 'κ²μμ΄κ° νμν©λλ€.' }, | ||
{ status: 400 } | ||
); | ||
} | ||
|
||
const response = await axiosInstance.get( | ||
`${API_BASE_URL.DNS}/api/user-service/nickname`, | ||
{ | ||
params: { | ||
string: queryString, | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
|
||
console.log('Search response:', response.data); | ||
return NextResponse.json(response.data); | ||
} catch (error) { | ||
console.error('Search error in API route:', error); | ||
return NextResponse.json( | ||
{ error: 'μ¬μ©μ κ²μμ μ€ν¨νμ΅λλ€.' }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters