본문 바로가기

엉터리 개발 이야기/Superset

[Superset][Flask-CORS][CORS] 'Access-Control-Allow-Origin' 해결

반응형

Angular2+ 에서 Superset API 호출 시 No 'Access-Control-Allow-Origin' header is present on the requested resource. 에러가 발생한다.

결론적으로 다른 도메인에서 호출하면 에러가 발생하니 조치가 필요하다.


CORS 문제 해결하기 위해 Flask-CORS 설치가 필요하다.


supserset/config.py 에서

#CORS Options

ENABLE_CORS = True 로 변경하고 재시작 해보면 flask_cors 가 없다고 나온다.


■ 해결방법


1. superset[cors] 설치

> pip install superset[cors]


2. config.py 에 설정

  - ENABLE_CORS = True ==> The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost:4200' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. 에러 발생

ENABLE_CORS = True
CORS_OPTIONS = { 'supports_credentials': True }

위와 같이 설정하면 정상 동작 하는 걸 확인할 수 있다.



   








반응형