Skip to content

Commit da94a84

Browse files
authored
Merge pull request #25 from AIVLE-School-Third-Big-Project/temp
✨: 추가 피팅 페이지
2 parents f56f8da + 4dea947 commit da94a84

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

Diff for: src/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const aiAPI = process.env.AI_API
1919
const allowedOrigins = [
2020
'http://localhost:3000',
2121
'http://localhost:3001',
22-
'http://www.model-fit.kro.kr',
22+
process.env.WEB_API,
23+
process.env.WEB_IP,
2324
aiAPI,
2425
]
2526

Diff for: src/routes/.FittingImage.js.swp

12 KB
Binary file not shown.

Diff for: src/routes/FittingImage.js

+22-16
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@ const fittingApiUrl = process.env.AI_FITTING_API_URL
88

99
async function isImageValid(imageUrl) {
1010
return new Promise((resolve, reject) => {
11-
https
12-
.head(imageUrl, (res) => {
13-
if (res.statusCode === 200) {
14-
resolve(true)
15-
} else {
16-
resolve(false)
17-
}
18-
})
19-
.on('error', (error) => {
20-
console.error(`Error checking image URL: ${imageUrl}`, error)
21-
resolve(false)
22-
})
23-
})
24-
}
11+
const options = {
12+
method: 'HEAD',
13+
url: imageUrl,
14+
};
15+
16+
const req = https.request(imageUrl, options, (res) => {
17+
if (res.statusCode === 200) {
18+
resolve(true);
19+
} else {
20+
resolve(false);
21+
}
22+
});
2523

24+
req.on('error', (error) => {
25+
console.error(`Error checking image URL: ${imageUrl}`, error);
26+
resolve(false);
27+
});
28+
29+
req.end();
30+
});
31+
}
2632
router.post('/fitting', async (req, res) => {
2733
try {
2834
const { userId, clothID } = req.body
@@ -62,18 +68,18 @@ router.post('/fitting', async (req, res) => {
6268
cloth_url: clothImageUrl,
6369
},
6470
})
65-
6671
if (response.data.success) {
6772
console.log('Fitting request sent successfully.')
6873

6974
const imageUrl = response.data.file_name
7075
await Clothes.updateOne(
71-
{ userId, clothesImageLink: clothUrl },
76+
{ userId, clothesImageLink: clothImageUrl },
7277
{ $set: { fittingImageLink: imageUrl } }
7378
)
7479

7580
res.status(200).json({ fittingImageLink: imageUrl })
7681
} else {
82+
console.log(error.response)
7783
console.error('Error:', response.data.error)
7884
res.status(500).json({ error: response.data.error })
7985
}

Diff for: style/src/api/apiConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const API_URL = 'http://localhost:3000'
1+
//export const API_URL = 'http://localhost:3000'
22
// 배포 시, 위 코드 주석처리 후 다음 코드로 변경
3-
// export const API_URL = 'http://www.model-fit.kro.kr'
3+
export const API_URL = 'http://model-fit.kro.kr'

Diff for: style/src/components/FittingPage/FittingPage.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function FittingPage() {
4343
isDefaultPage={isDefaultPage}
4444
setErrorCode={setErrorCode}
4545
showAlert={showAlert}
46+
setIsDefaultPage={setIsDefaultPage}
4647
/>
4748
<div className="empty-space" />
4849
<RightFitContainer

Diff for: style/src/components/FittingPage/LeftFitContainer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function LeftFitContainer({
1414
showAlert,
1515
fittingImage,
1616
isDefaultPage,
17+
setIsDefaultPage,
1718
}) {
1819
const [image, setImage] = useState('')
1920

@@ -43,7 +44,7 @@ function LeftFitContainer({
4344

4445
return (
4546
<div>
46-
<ButtonBar setErrorCode={setErrorCode} showAlert={showAlert} />
47+
<ButtonBar setErrorCode={setErrorCode} showAlert={showAlert} setIsDefaultPage={setIsDefaultPage} />
4748
<div className={styles.imageContainer}>
4849
<img
4950
className={styles.fittingImage}

0 commit comments

Comments
 (0)