반응형
축삭의 교차 영역
axios용 jquery ajax를 변경하는데 크로스 도메인이 있는 axios를 사용할 수 없습니다.
axios.get(myurl, {
headers: { 'crossDomain': true },
}).then(res => {
console.log(res);
}).catch(error => {
console.log('erro', error);
})
jquery 코드가 작동 중입니다.
$.ajax({
type: 'GET',
crossDomain: true,
url:myurl,
success: (res) => {},
error: (fail) => {}
})
오류: Request Header 필드 crossDomain이 비행 전 응답에서 Access-Control-Allow-Headers에 의해 허용되지 않습니다.
누가 나를 도와줄 수 있나요?
"crossDomain"은 헤더에 있을 필요가 없습니다.
axios.get(myurl, {
crossDomain: true
}).then(res => {
console.log(res);
}).catch(error => {
console.log('error', error);
})
안부 전해요
나의 경우 @nuxtjs/proxy 해결된 문제
https://nuxtjs.org/faq/http-proxy/
nuxt.config.js에 @nuxtjs/proxy를 삽입하고 프록시 설정을 편집했습니다.
api server와 rest api를 사용했습니다.
proxy: {
'/api': {
target: 'http://127.0.0.1:8080',
pathRewrite: {
'^/api' : '/api'
},
},
'/zip': {
target: 'http://zipcloud.ibsnet.co.jp',
pathRewrite: {
'^/zip' : '/api'
}
}
}
언급URL : https://stackoverflow.com/questions/42422494/cross-domain-at-axios
반응형
'programing' 카테고리의 다른 글
div 클릭 시 fireing focus 이벤트 방지 (0) | 2023.10.07 |
---|---|
NSUserDefaults에 값을 저장하는 데 제한이 있습니까? (0) | 2023.10.07 |
XPath: 속성이 존재하는지 확인하는 방법은 무엇입니까? (0) | 2023.10.07 |
각도2: 배열을 관측 가능으로 변환 (0) | 2023.10.07 |
Chocolatey와 패키지 목록을 설치하는 PowerShell 스크립트 (0) | 2023.10.07 |