Hello. @김경한0184
This CORS error is related to the integrity check of the Cocoa SDK. I can suggest several methods to solve it:
- Simplest Solution - remove the integrity property:
<Script
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.4/kakao.min.js"
onLoad={() => {
setKakaoLoaded(true);
}}
onError={(e) => {
console.log(e);
}}
/>
- Add crossOrigin property:
<Script
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.4/kakao.min.js"
integrity="sha384-DKYJZ8NLiK8MN4/C5P2dtSmLQ4KwPaoqAfyA/DfmEc1VDxu4yyC7wy6K1Hs90nka"
crossOrigin="anonymous"
onLoad={() => {
setKakaoLoaded(true);
}}
onError={(e) => {
console.log(e);
}}
/>
- What you need to do in Kakao Developers Console:
- Go to web platform settings
- Add localhost:3000 with the full URL format:
http://localhost:3000
- If you are using HTTPS:
https://localhost:3000
- Add your production domain
- CORS setting in your Next.js config file:
// next.config.js
module.exports = {
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*'
}
]
}
]
}
}
I recommend you to try the first of these solutions (removing the integrity property). If this does not work, you can follow the other steps in order.
If the error persists, check the following:
- Is the correct domain registered in the Kakao Developers Console?
- Is your JavaScript SDK key correct?
- Does your Next.js project have CORS middleware?