프로그래밍/web Programming

[swagger] swagger UI cors 해결

jinkwon.kim 2023. 2. 27. 08:42
728x90
반응형

개요

beego + swagger를 사용하려고 할때   swagger 실행 서버랑 web brower 실행 ip가 다를때 cors오류가 발생 하는데 이를 해결하는 방법을 남깁니다. 

현상

Fetch error

Failed to fetch https://petstore.swagger.io/v2/swagger.json

Fetch error

Possible cross-origin (CORS) issue? The URL origin (https://petstore.swagger.io) does not match the page (http://1.1.1.1). Check the server returns the correct 'Access-Control-Allow-*' headers.

해결법

swagger 디렉토리 하위에 있는 index.html 파일의 url 부분을 webserver ip로 수정 하면 됩니다.

유의 사항

swagger 경로지정을 알맞게 해주어아 합니다.
단순 ip만 변경하면 동작 하지 않습니다.

728x90
반응형
댓글수0