songining
react - flask CORS ์—๋Ÿฌ ํ•ด๊ฒฐ
BACKEND/Flask 2021. 11. 11. 19:35

๋‹ค๋ฅธ ํฌํŠธ๋ฒˆํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋‘ ์„œ๋ฒ„๊ฐ„ ํ†ต์‹ ์„ ํ•  ๋•Œ ์ƒ๊ธฐ๋Š” ๋ณด์•ˆ์—๋Ÿฌ์ด๋‹ค. React์—์„œ axios๋กœ ํผ ์ „์†ก์‹œ, React axios.defaults.withCredentials = true; Flask pip install flask_cors ๋ชจ๋“ˆ ์„ค์น˜ ํ›„ app = Flask(__name__) CORS(app, supports_credentials=True) # ๋‹ค๋ฅธ ํฌํŠธ๋ฒˆํ˜ธ์— ๋Œ€ํ•œ ๋ณด์•ˆ ์ œ๊ฑฐ api = Api(app) ์œ„์™€ ๊ฐ™์ด ์จ์ฃผ๋ฉด ํ•ด๊ฒฐ๋œ๋‹ค!! ๋‹ค๋ฅธ ํฌํŠธ๋ผ๋ฆฌ ํ†ต์‹ ํ• ๋•Œ ์ฟ ํ‚ค๊ฐ’์ด ์ž๋™์œผ๋กœ ์ถ”๊ฐ€๋˜์ง€์•Š์•„ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ์˜€๋‹ค.