From 5e359bb0baea127475d2de9c0db388c16aadb6ea Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 14 May 2025 10:54:16 +0900 Subject: [PATCH 1/4] fix: update API host URL and S3 base URL in environment files; refactor useRefFiles hook to utilize environment variables for API endpoints --- .env.development | 4 ++-- .env.production | 2 +- qcast3.database.sqlite | Bin 16384 -> 16384 bytes src/hooks/common/useRefFiles.js | 16 +++++++++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.env.development b/.env.development index 1ca922e7..e6e38032 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ NEXT_PUBLIC_API_SERVER_PATH="http://1.248.227.176:38080" NEXT_PUBLIC_HOST_URL="//1.248.227.176:4000" -NEXT_PUBLIC_API_HOST_URL="http://1.248.227.176:5000" +NEXT_PUBLIC_API_HOST_URL="http://1.248.227.176:3000" SESSION_SECRET="i3iHH1yp2/2SpQSIySQ4bpyc4g0D+zCF9FAn5xUG0+Y=" @@ -24,4 +24,4 @@ AWS_REGION="ap-northeast-1" AMPLIFY_BUCKET="files.hanasys.jp" AWS_ACCESS_KEY_ID="AKIA3K4QWLZHFZRJOM2E" AWS_SECRET_ACCESS_KEY="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" -NEXT_PUBLIC_AWS_S3_BASE_URL="http://files.hanasys.jp.s3-website-ap-northeast-1.amazonaws.com" \ No newline at end of file +NEXT_PUBLIC_AWS_S3_BASE_URL="//files.hanasys.jp" \ No newline at end of file diff --git a/.env.production b/.env.production index 3842b041..b2d50cdd 100644 --- a/.env.production +++ b/.env.production @@ -18,4 +18,4 @@ AWS_REGION="ap-northeast-2" AMPLIFY_BUCKET="interplug" AWS_ACCESS_KEY_ID="AKIAVWMWJCUXFHEAZ4FR" AWS_SECRET_ACCESS_KEY="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" -NEXT_PUBLIC_AWS_S3_BASE_URL="https://interplug.s3.ap-northeast-2.amazonaws.com" \ No newline at end of file +NEXT_PUBLIC_AWS_S3_BASE_URL="//files.hanasys.jp" \ No newline at end of file diff --git a/qcast3.database.sqlite b/qcast3.database.sqlite index 166f2da26bfaf6d977a400c5ef8dd5a21ef49896..6a7a809a38f22f297032357b29759527ebbd7c22 100644 GIT binary patch delta 170 zcmZo@U~Fh$oFL6;K2gS*(R^dVe0^SNUIqpRM*bZP{5$yLHuD&`^4F(|u`!5pHaeTe zh_f+7NP{_=riP{#86_nJ#a8f<)OEL^&H}O-#%zCm*#p5-lyr$xlqt&#f#j%+bxsPtVuODoCBY-QE)b D->Vyv diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js index 3be7fff2..94f7a8df 100644 --- a/src/hooks/common/useRefFiles.js +++ b/src/hooks/common/useRefFiles.js @@ -89,7 +89,7 @@ export function useRefFiles() { setPopSpinnerStore(true) console.log('๐Ÿš€ ~ handleFileDelete ~ handleFileDelete:', refImage) console.log('๐Ÿš€ ~ handleFileDelete ~ currentCanvasPlan.bgImageName:', currentCanvasPlan.bgImageName) - await del({ url: `http://localhost:3000/api/image/upload?fileName=${currentCanvasPlan.bgImageName}` }) + await del({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/upload?fileName=${currentCanvasPlan.bgImageName}` }) // setRefImage(null) setCurrentBgImage(null) // setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: null })) @@ -112,7 +112,7 @@ export function useRefFiles() { confirmFn: async () => { console.log('๐Ÿš€ ~ handleAddressDelete ~ handleAddressDelete:', refImage) console.log('๐Ÿš€ ~ handleAddressDelete ~ currentCanvasPlan.bgImageName:', currentCanvasPlan.bgImageName) - await del({ url: `http://localhost:3000/api/image/map?fileName=${currentCanvasPlan.bgImageName}` }) + await del({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/map?fileName=${currentCanvasPlan.bgImageName}` }) setMapPositionAddress('') setCurrentBgImage(null) // setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null })) @@ -147,7 +147,7 @@ export function useRefFiles() { // url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`, // }) const res = await get({ - url: `http://localhost:3000/api/image/map?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`, + url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/map?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`, }) console.log('๐Ÿš€ ~ handleMapImageDown ~ res:', res) // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) @@ -211,12 +211,13 @@ export function useRefFiles() { // data: formData, // }) const res = await post({ - url: `http://localhost:3000/api/image/upload`, + url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/upload`, data: formData, }) console.log('๐Ÿš€ ~ handleUploadImageRefFile ~ res:', res) // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) - setCurrentBgImage(`${res.filePath}`) + // setCurrentBgImage(`${res.filePath}`) + setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) setRefImage(file) const params = { @@ -244,12 +245,13 @@ export function useRefFiles() { /** ์บ๋“œ ๋„๋ฉด ํŒŒ์ผ ์—…๋กœ๋“œ */ const result = await post({ - url: `http://localhost:3000/api/image/cad`, + url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/cad`, data: res, }) console.log('๐Ÿš€ ~ handleUploadConvertRefFile ~ result:', result) - setCurrentBgImage(`${result.filePath}`) + // setCurrentBgImage(`${result.filePath}`) + setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) setRefImage(file) const params = { From ad12f9b8172c52551e39fe454c206b460922c0fb Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 14 May 2025 10:59:15 +0900 Subject: [PATCH 2/4] fix: update API host URL in development environment file --- .env.development | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.development b/.env.development index e6e38032..d3e1ba88 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ NEXT_PUBLIC_API_SERVER_PATH="http://1.248.227.176:38080" NEXT_PUBLIC_HOST_URL="//1.248.227.176:4000" -NEXT_PUBLIC_API_HOST_URL="http://1.248.227.176:3000" +NEXT_PUBLIC_API_HOST_URL="http://1.248.227.176:5000" SESSION_SECRET="i3iHH1yp2/2SpQSIySQ4bpyc4g0D+zCF9FAn5xUG0+Y=" From e26673b78a31500dc1b5252c75c39177750fa448 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 14 May 2025 11:03:43 +0900 Subject: [PATCH 3/4] fix: update background image URL in useRefFiles hook to utilize AWS S3 base URL --- src/hooks/common/useRefFiles.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js index 94f7a8df..7d2cc0fa 100644 --- a/src/hooks/common/useRefFiles.js +++ b/src/hooks/common/useRefFiles.js @@ -151,7 +151,8 @@ export function useRefFiles() { }) console.log('๐Ÿš€ ~ handleMapImageDown ~ res:', res) // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) - setCurrentBgImage(`${res.filePath}`) + // setCurrentBgImage(`${res.filePath}`) + setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) await setBackGroundImage({ objectId: currentCanvasPlan.id, From 4bff451dc4167e05800a32de658bce6d918eaa1d Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 14 May 2025 11:22:50 +0900 Subject: [PATCH 4/4] refactor: enhance useRefFiles hook with additional comments and improve file handling logic for background images --- src/hooks/common/useRefFiles.js | 39 ++++++++++----------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js index 7d2cc0fa..d13e7213 100644 --- a/src/hooks/common/useRefFiles.js +++ b/src/hooks/common/useRefFiles.js @@ -16,6 +16,9 @@ import { popSpinnerState } from '@/store/popupAtom' * ์ด๋ฏธ์ง€ -> ์บ”๋ฒ„์Šค ๋ฐฐ๊ฒฝ์— ์ด๋ฏธ์ง€ ๋กœ๋“œ * ์ฃผ์†Œ -> ๊ตฌ๊ธ€ ๋งต์—์„œ ์ฃผ์†Œ ๊ฒ€์ƒ‰ ํ›„ ์ด๋ฏธ์ง€๋กœ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์•„์„œ ์บ”๋ฒ„์Šค ๋ฐฐ๊ฒฝ์— ์ด๋ฏธ์ง€ ๋กœ๋“œ * .dwg -> api๋ฅผ ํ†ตํ•ด์„œ .png๋กœ ๋ณ€ํ™˜ ํ›„ ์บ”๋ฒ„์Šค ๋ฐฐ๊ฒฝ์— ์ด๋ฏธ์ง€ ๋กœ๋“œ + * + * setCurrentBgImage ์— ์ด๋ฏธ์ง€๋ฅผ ์„ธํŒ…ํ•˜๋ฉด ๋„๋ฉด์— ๋ฐฐ๊ฒฝ์œผ๋กœ ๋กœ๋”ฉ๋œ๋‹ค. + * ๋‹ค๋งŒ S3 Response์— aws ๊ณ ์œ  ์ฃผ์†Œ๊ฐ€ ๋‚˜์˜ค๋Š”๋ฐ ์—ฌ๊ธฐ์„œ๋Š” cloudfront ์‚ฌ์šฉ์„ ์œ„ํ•ด์„œ NEXT_PUBLIC_AWS_S3_BASE_URL ๋„๋ฉ”์ธ์„ ์‚ฌ์šฉํ•œ๋‹ค. * @returns {object} */ export function useRefFiles() { @@ -41,6 +44,7 @@ export function useRefFiles() { }, [refFileMethod]) /** + * ์ตœ์ดˆ input type="file" ์— ๋Œ€ํ•œ ์ด๋ฒคํŠธ * ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ๋ฒ„ํŠผ ์ปจํŠธ๋กค * @param {*} file */ @@ -61,6 +65,10 @@ export function useRefFiles() { } } + /** + * ํ—ˆ์šฉํ•˜๋Š” ํŒŒ์ผ์ธ์ง€ ์ฒดํฌํ•œ๋‹ค + * @param {File} file + */ const refFileSetting = (file) => { console.log('๐Ÿš€ ~ refFileSetting ~ file:', file) if (file.name.split('.').pop() === 'dwg') { @@ -79,7 +87,7 @@ export function useRefFiles() { } /** - * ํŒŒ์ผ ์‚ญ์ œ + * ์ด๋ฏธ์ง€ ํŒŒ์ผ ์‚ญ์ œ */ const handleFileDelete = async () => { swalFire({ @@ -90,9 +98,7 @@ export function useRefFiles() { console.log('๐Ÿš€ ~ handleFileDelete ~ handleFileDelete:', refImage) console.log('๐Ÿš€ ~ handleFileDelete ~ currentCanvasPlan.bgImageName:', currentCanvasPlan.bgImageName) await del({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/upload?fileName=${currentCanvasPlan.bgImageName}` }) - // setRefImage(null) setCurrentBgImage(null) - // setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: null })) await deleteBackGroundImage({ objectId: currentCanvasPlan.id, planNo: currentCanvasPlan.planNo, @@ -103,7 +109,7 @@ export function useRefFiles() { } /** - * ์ฃผ์†Œ ์‚ญ์ œ + * ์ฃผ์†Œ ๋งต ์ด๋ฏธ์ง€ ์‚ญ์ œ */ const handleAddressDelete = async () => { swalFire({ @@ -115,7 +121,6 @@ export function useRefFiles() { await del({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/map?fileName=${currentCanvasPlan.bgImageName}` }) setMapPositionAddress('') setCurrentBgImage(null) - // setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null })) await deleteBackGroundImage({ objectId: currentCanvasPlan.id, planNo: currentCanvasPlan.planNo, @@ -125,7 +130,7 @@ export function useRefFiles() { } /** - * ์ฃผ์†Œ๋กœ ๊ตฌ๊ธ€ ๋งต ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ + * ์ฃผ์†Œ๋กœ ๊ตฌ๊ธ€ ๋งต ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œํ•˜์—ฌ ์บ”๋ฒ„์Šค ๋ฐฐ๊ฒฝ์œผ๋กœ ๋กœ๋“œ */ const handleMapImageDown = async () => { console.log('๐Ÿš€ ~ handleMapImageDown ~ handleMapImageDown:') @@ -143,15 +148,10 @@ export function useRefFiles() { option1: newOption1, })) - // const res = await get({ - // url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`, - // }) const res = await get({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/map?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`, }) console.log('๐Ÿš€ ~ handleMapImageDown ~ res:', res) - // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) - // setCurrentBgImage(`${res.filePath}`) setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) await setBackGroundImage({ @@ -207,17 +207,11 @@ export function useRefFiles() { const formData = new FormData() formData.append('file', file) - // const res = await post({ - // url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/upload`, - // data: formData, - // }) const res = await post({ url: `${process.env.NEXT_PUBLIC_API_HOST_URL}/api/image/upload`, data: formData, }) console.log('๐Ÿš€ ~ handleUploadImageRefFile ~ res:', res) - // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) - // setCurrentBgImage(`${res.filePath}`) setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) setRefImage(file) @@ -251,7 +245,6 @@ export function useRefFiles() { }) console.log('๐Ÿš€ ~ handleUploadConvertRefFile ~ result:', result) - // setCurrentBgImage(`${result.filePath}`) setCurrentBgImage(`${process.env.NEXT_PUBLIC_AWS_S3_BASE_URL}/${res.fileName}`) setRefImage(file) @@ -263,16 +256,6 @@ export function useRefFiles() { } console.log('๐Ÿš€ ~ handleUploadImageRefFile ~ params:', params) await setBackGroundImage(params) - - // const res = await post({ url: converterUrl, data: formData }) - // console.log('๐Ÿš€ ~ handleUploadConvertRefFile ~ res:', res) - // const result = await post({ - // url: `${process.env.NEXT_PUBLIC_HOST_URL}/cad/convert`, - // data: res, - // }) - // console.log('๐Ÿš€ ~ handleUploadConvertRefFile ~ result:', result) - // setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${result.filePath}`) - // setRefImage(res.Files[0].FileData) } /**