์์งํ ๋ฐฐํฌ๋ ๋๋ฑ ๋ ์ค ์์๋ค ใ
Movyes ํ๋ก์ ํธ๋ฅผ gh-page๋ก ๋ฐฐํฌํ๋ฉด์ ๋ง๋ ์๋ฌ๋ฅผ ์ ๋ฆฌํด๋ณด๋ ค๊ณ ํ๋ค.
Creating an optimized production build...
Failed to compile.Module not found: Error: Can't resolve 'assert' in 'C:\Users\yeon\Desktop\FRONTEND\projects\movie\node_modules\yargs\lib\platform-shims'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modulThis is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }
ํ๋ก์ ํธ deploy์ ์คํจํ๋ฉด์ ๋ฐ์.
ํ์ผ์ ํ๊ฒฝ๋ณ์๋ฅผ ๋ฃ์ ๋ ์ค์๋ก import { env } from "yargs
๊ฐ ์ถ๊ฐ๋์ด ๋ฐ์ํจ.
import๋ฅผ ์ญ์ ํ๋๊น ์ฌ๋ผ์ก๋ค.
๋ฐฐํฌ์ ์ฑ๊ณตํ๊ณ ์น์ฌ์ดํธ์ ์ ์ํ๋๋ ๋๋ฅ..! ๋ณ์๊ฐ ๋จ๋ ์๋ ํ์ด์ง์
๋๋ค๐ฅ
์ฒ์์๋ ๋ ๋ฐฐํฌ๊ฐ ์ ๋๋ก ์๋๊ฑด๊ฐ ์ถ์๋๋ฐ gh-page์์ ์ ๊ณตํ๋ 404ํ์ด์ง๊ฐ ์๋ ๋ด๊ฐ ์ค์ ํ NotFound
์ปดํฌ๋ํธ๊ฐ ๋จ๋๊ฑธ ๋ณด๋ ๋ฐฐํฌ๋ ์ฑ๊ณตํ ๋ฏ ์ถ์๋ค.
๊ทธ๋ ๋ค๋ฉด ๋จ์๊ฑด ํ๋.
๋ผ์ฐํ ..!
์ก์๋ค ์๋!
ํ์ง๋ง ์๋ฌด๋ฆฌ ์ดํด๋ด๋ ๊ฒฝ๋ก๋ ๋ฌธ์ ๊ฐ ์ ์๊ณ ... (์ ์ด์ ๊ทธ๊ฒ ๋ฌธ์ ์์ผ๋ฉด ๋ก์ปฌ์์๋ ์๋์ํ ๋ฐ ๋ก์ปฌ์์ ๋ฌธ์ ๊ฐ ์์์) ๋ญ๊ฐ ๋ฌธ์ ์ผ๊น... ํ์ฐธ ๊ตฌ๊ธ๋งํ๋ค ๋๋์ด ์์ธ์ ์ฐพ์๋ค.
์ฐธ๊ณ ์๋ฃ: https://tlsdnjs12.tistory.com/68?category=1029328
๊ฐ๋จํ ๋งํ์๋ฉด
ํ๋ก์ ํธ์ ๋ผ์ฐํฐ๊ฐ ๊ฐ๋ฆฌํค๋ '/' ๊ฒฝ๋ก๋ 'https://๋ฐฐํฌ์ฌ์ดํธ/' ์์์ '/' ์ธ๋ฐ
์ค์ ๋ฐฐํฌ๋ 'https://๋ฐฐํฌ์ฌ์ดํธ/๋ ํฌ์งํฐ๋ฆฌ์ด๋ฆ/' ๊ฒฝ๋ก์ ๋ฐฐํฌ๋๊ธฐ ๋๋ฌธ์ด๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋ ๊ฐ์ง๋ฅผ ์ฐพ์๋ค.
BrowserRoute
๋์ HashRoute
๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ.
BroswerRoute
์ basename=process.env.PUBLIC_URL
์ ์ค์ ํด์ค๋ค.
๊ทธ๋ฌ๋ฉด ์๋์ผ๋ก ํ๋ก์ ํธ์ ๋ฒ ์ด์ค ๊ฒฝ๋ก๊ฐ /public_URL
๋ก ๋ฐ๋๋ค.
๋๋ ์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋๋ฐBrowserRoute
๊ฐ ์๋ createBrowserRouter
๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ๊ณต์ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํด์ ๋๋ฒ์งธ ์ธ์๊ฐ์ผ๋ก ํด๋น ์์ฑ์ ์ง์ ํด์ฃผ์๋ค.
๊ณต์๋ฌธ์: https://reactrouter.com/en/main/routers/create-browser-router
๋์ด์ ๋นํ๋ฉด์ด ๋จ์ง ์์ง๋ง ๋ฉ์ธ ํ์ด์ง์์ API๋ฅผ ํธ์ถํ ๋ 404 ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. (๊ทธ๋ง..!)
๋คํธ์ํฌ ํญ์์ API ์์ฒญ์ด ์ด๋๋ก ๊ฐ๋์ง ํ์ธํ๋๋ฐ ๋ด ๋ฐฐํฌ ์ฌ์ดํธ ๊ฒฝ๋ก/API ์๋ํฌ์ธํธ
์ผ๋ก ์์ฒญ๋๊ณ ์์๋ค.
๊ฐ๋ฐํ ๋ CORS ์๋ฌ๊ฐ ๋ฐ์ํด์ proxy ์ฒ๋ฆฌ๋ฅผ ํ์๋๋ฐ ๊ทธ๊ฒ ๋๋ฌธ์ธ ๊ฒ ๊ฐ์๋ค.
proxy์ฒ๋ฆฌ๋ฅผ ์ ๊ฑฐํ๋ 404 ์๋ฌ๋ ์ฌ๋ผ์ก์ง๋ง ์๋ก์ด ์๋ฌ๊ฐ ๋ฐ์ํ๋ค!
Mixed Content: The page at 'https://ohy9205.github.io/movie/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.koreafilm.or.kr/openapi-data2/wisenut/search_api?collection=kmdb_new2&ServiceKey=RIR3C4XJSZ780D6XH891&detail=Y&listCount=50&releaseDts=20221229&releaseDte=20230112'. This request has been blocked; the content must be served over HTTPS.
๋ฐฐํฌ ์ฌ์ดํธ๋ https
์ธ๋ฐ API๋ http
์ด๋ผ์ ๋ฐ์ํ๋ ์๋ฌ.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก๋ ๋ ๊ฐ์ง๋ฅผ ์ฐพ์๋ค.
๋ธ๋ผ์ฐ์ ์ค์ ์ฐฝ์์ ์์ ํ์ง ์์ ์ฝํ
์ธ ์ฐจ๋จ->ํ์ฉ ์ผ๋ก ๋ฐ๊พธ๋ฉด ๋๋ ๋ฐฉ๋ฒ์ธ๋ฐ...
ํ์ค์ ์ผ๋ก ์ฌ์ฉ์๋ณด๊ณ ์ผ์ผ์ด ์ค์ ํ๋ผ๊ณ ํ ์ ์์ง ์์๊น.
/pubic/index.html
์ meta
ํ๊ทธ ์ถ๊ฐ
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
๋ด๊ฐ ์ ํํ ๋ฐฉ๋ฒ.
header
์์ ํด๋น ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ฉด ๋๋ค.
ํฌ์คํฐ ์์๋ ๋ณด์ฌ์ฃผ๋ ์ด๋ฏธ์ง๋ฅผ /public/assets
๊ฒฝ๋ก์ ๋ฃ์ด๋๊ณ img src='/assets/ํ์ผ๋ช
'
์ผ๋ก ๊ฒฝ๋ก๋ฅผ ์ง์ ํด๋๋๋ฐ ๋ผ์ฐํธ์ basename์ฒ๋ฆฌ๋ฅผ ํ๋ฉด์ ๊ฒฝ๋ก๊ฐ ๋ฐ๋์ด ๊ฐ์ ธ์ค์ง ๋ชปํ๋ ํ์์ด ๋ฐ์ํ๋ค.
์ด๋ฏธ์ง ๊ฒฝ๋ก๋ /process.env.PUBLIC_URL/assets/
์ฒ๋ผ ๋ณ๊ฒฝํ๋ ใ
ฃํด๊ฒฐ๋๋ค.
์ด์ ๋ฐฐํฌ์์ ๋ฐ์ํ ๋ฌธ์ ๋ฅผ ์ ๋ฆฌํด ๋ณด์๋ค.
์ฐ๋ฆฌ ๋ค์์ ๋ฐฐํฌ๋๋ ๋ง๋์ง ๋ง์~~