본문 바로가기
category/web

from origin 'null' has been blocked by cors policy [CORS error]

by 자운대고라니 2022. 8. 8.
반응형

가끔 local  환경에서 html 파일을 구동할때 그림과 같은 에러가 발생한다.

버전이 업데이트되면서 발생한 에러로, 서버에서 구동시키면 문제없이 작동한다.

해결 방법이 여러개가 존재하나, chrome 설정을 추천한다.

 

해결방법

- chrome 바로가기를 생성한다. (바탕화면에 있는 바로가기를 복사해도 된다.)

- 만들어진 아이콘을 우클릭하고 속성을 눌러본다.

- 아래와 같이 기존 경로에 명령어를 삽입해준다.

 

--disable-web-security --disable-web-security --user-data-dir=%LOCALAPPDATA%\Google\chromeTemp -–allow-file-access-from-files

 

기존 경로에 위에 있는 명령어를 입력한다.

 

(기존 경로)

"C:\Program Files\Google\Chrome\Application\chrome.exe"

 

(기존 경로 + 명령어)

"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-web-security --user-data-dir=%LOCALAPPDATA%\Google\chromeTemp -–allow-file-access-from-files

 

안되면 댓글 남겨주세요. ^^

 

참고 자료

https://bongra.tistory.com/143

 

[JS] from origin 'null' has been blocked by CORS policy: 에러..

오늘 Vue를 만지작 거리고 있는데, 다음과 같은 에러가 났다. 내 PC에 있는 내가 만든 저 testInstance.js를 쓰려는데, CORS에러가 뜨는 것.. 즉 SOP가 보안 때문에 막았으니 허용을 해줘라 인데, 내 로컬

bongra.tistory.com

 

반응형

댓글