๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋ชฉ๋กํ‹ฐ์Šคํ† ๋ฆฌ์ฑŒ๋ฆฐ์ง€ (1)

JiYoung Dev ๐Ÿ–ฅ

[Node.js] Express์˜ listen ๋ฐ Cors ์„ค์ •

์–ด์ œ ์ž‘์„ฑํ–ˆ๋˜ Nginx์—์„œ Reverse Proxy ์„ค์ • ํ›„ Spring Server์—์„œ Cors ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ Spring Security Cors ์„ค์ •์— ์™ธ๋ถ€๋ง ์ฃผ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•ด ํ•ด๊ฒฐํ•˜์˜€๋‹ค๊ณ  ํ•˜์˜€๋‹ค. ํ•ด๋‹น ๊ธ€์—์„œ๋Š” ์ž‘์„ฑํ•˜์ง€ ์•Š์•˜์ง€๋งŒ Node.js Express ์„œ๋ฒ„์—์„œ๋„ Cors ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋Š”๋ฐ Cors ์„ค์ •๊ณผ ํ•จ๊ป˜ app.listen("0.0.0.0")์„ ์ถ”๊ฐ€ํ•จ์œผ๋กœ์จ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.  ์œ„์˜ ๊ณผ์ •์„ ์ง„ํ–‰ํ•˜๋ฉด์„œ Cors๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฒƒ๊ณผ app.listen("0.0.0.0")์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์–ด๋–ค ์ฐจ์ด๊ฐ€ ์žˆ๋Š”์ง€ ์•Œ์•„๋ณด์•˜๋‹ค. ๐Ÿ”Ž Cors ์„ค์ •์˜ ์—ญํ• Cors(Cross-Origin Resource Sharing)๋Š” ์›น ๋ธŒ๋ผ์šฐ์ € ๋ฐœ์ƒํ•˜๋Š” ๋ณด์•ˆ ์ •์ฑ…์œผ๋กœ ํด๋ผ์ด์–ธํŠธ์˜ ์ถœ์ฒ˜(Origin)์— ๋”ฐ๋ผ ์„œ..

full stack/Back-End 2024. 11. 7. 22:10