๐Ÿ“† 23.01.15 - Mixed Content

๋ฒ„๋“คยท2023๋…„ 1์›” 15์ผ
0

โœจToday I Learn (TIL)

๋ชฉ๋ก ๋ณด๊ธฐ
22/62

netlify CI / CD ์ž๋™ํ™” ๊ณผ์ •์—์„œ ์˜ค๋ฅ˜ 127๋ฒˆ์ด๋ผ๋Š” ์นœ๊ตฌ๋ฅผ ๋งŒ๋‚˜์„œ ์–ด๋ ค์›€์„ ๊ฒช๋˜ ์ฐฐ๋‚˜์— npm run build ํ•˜์—ฌ ๋งŒ๋“  ๋นŒ๋“œ ํด๋”๋ฅผ ์ง์ ‘ ๋ฐฐํฌํ•˜์—ฌ ์„œ๋น„์Šค๋ฅผ ๋ฐฐํฌํ•˜๋Š”๋ฐ ์„ฑ๊ณต์„ ํ•˜์˜€๋‹ค.

๊ทธ๋Ÿฌ๋‚˜ axios ์š”์ฒญ์„ ํ•˜๋Š”๋ฐ response ๊ฐ’์ด ํ˜ธ์ถœ์ด ์ž˜๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ๋ฅผ ๋ฐœ๊ฒฌํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ์—๋Ÿฌ ๋‚ด์šฉ์€ ์œ„์˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์€๋ฐ, ํ•˜๋‹จ์˜ This request has been blocked ๋ผ๋Š” ๋ง๋งŒ ๋ณด์•˜์„ ๋•Œ ์•ฝ๊ฐ„ CORS ์—๋Ÿฌ์™€ ๋น„์Šทํ•˜์—ฌ CORS ๋ฌธ์ œ๋กœ ์ฐฉ๊ฐ์„ ํ•  ์ˆ˜๋„ ์žˆ์—ˆ๋‹ค.

Mixed Content

๊ฒฐ๋ก ์ ์œผ๋กœ ์ด ์—๋Ÿฌ๋Š” https ํ™˜๊ฒฝ์œผ๋กœ ๋ฐฐํฌ๋œ ์‚ฌ์ดํŠธ๊ฐ€ http ์„œ๋ฒ„์˜ api ์— ์ ‘๊ทผํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์š”๊ตฌํ•˜์˜€์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ๋ผ๊ณ  ํ•œ๋‹ค.

ํ•ด๋‹น api ์ฃผ์†Œ๋ฅผ http ์—์„œ https ๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ ๋ถ€๋ฅด๊ฒŒ๋˜๋ฉด ๋ฌธ์ œ๋Š” ์—†๋‹ค๋งŒ, ๋งŒ์•ฝ http ์ฃผ์†Œ๋กœ ์š”์ฒญ์„ ํ•ด์•ผ๋  ์‹œ์—, ์–ด๋–ป๊ฒŒํ•ด์•ผ ํ•˜๋Š๋ƒ..

์ด ์„œ๋น„์Šค๋Š” ์ž๋™ํ™”๋ฅผ ํ•˜์ง€ ์•Š๊ณ  build ๋ช…๋ น์–ด๋กœ ๋งŒ๋“  ๋นŒ๋“œ ํŒŒ์ผ์„ ์ง์ ‘ ์ฒจ๋ถ€ํ•˜์—ฌ ๋ฐฐํฌํ•œ ์‚ฌ์ดํŠธ์ด๊ธฐ ๋•Œ๋ฌธ์— index.html์„ ๊ฑด๋“ค์—ฌ์„œ ์ˆ˜์ • ํ›„ ๋ฐฐํฌํ•˜๋ฉด ํ•ด๊ฒฐ์ด ๋œ๋‹ค.

<meta
      http-equiv="Content-Security-Policy"
      content="upgrade-insecure-requests" />

meta ํƒœ๊ทธ๋ฅผ ๋„ฃ๋Š” ๋ถ€๋ถ„์— ์œ„์˜ ์ฝ”๋“œ๋ฅผ ๊ธฐ์ž…์„ ํ•˜๋ฉด https ํ™˜๊ฒฝ์—์„œ๋„ http api call ์„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ๋œ๋‹ค.

profile
ํƒœ์–ด๋‚œ ๊น€์— ๋งŽ์€ ๊ฒฝํ—˜์„ ํ•˜๋ ค๊ณ  ์•„๋“ฑ๋ฐ”๋“ฑ ์• ์“ฐ๋Š” ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€