안녕하세요, 프로젝트에서 Next.js TypeScript를 사용하여 https://www.chiefdelphi.com/u/ereeen1208/summary.json 에 위치한 사용자 데이터(summary.json)에 접근하려고 합니다. (chiefdelphi는 FRC를 위한 Discourse 포럼입니다.) 여러 방법을 시도해 보았지만, 각 방법마다 오류가 발생하거나 성공하지 못했습니다:
(모든 예시에서 url = “https://www.chiefdelphi.com/u/ereeen1208/summary.json” 입니다)
빈 응답을 반환하는 코드:
const response = await fetch(url, {
mode: "no-cors",
method: "GET"
})
CORS 오류를 반환하는 코드:
const response = await fetch(url, {
mode: "cors",
method: "GET"
})
const { data } = await axios.get(url);
fetch() 오류:
Access to fetch at ‘https://www.chiefdelphi.com/u/ereeen1208/summary.json’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
axios.get() 오류:
Access to XMLHttpRequest at ‘https://www.chiefdelphi.com/u/unpicasso/summary.json’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
이 URL에서 데이터를 가져오기 위해 무엇을 할 수 있을까요? 다른 웹 스크래핑 방법을 시도해야 하거나 더 많은 매개변수를 추가해야 하나요? 감사합니다.