JavaScript
DB

node.js와 MariaDB를 연결할 때 오류가 나서 답답합니다

mo

monsterbell42
답변 대기중
30 XP

node.jsMariaDB를 연결 할 때 오류가 나서 답답합니다. cloudtype이라는 클라우드에 올려두고 실행하고 있는데요. 자꾸 UNSUPPORTED_AUTH_METHODAUTH_SWITCH_PLUGIN_ERROR가 뜨네요... 모듈을 mysql2로 바꾸기, ALTER USER 입력하기 등등 여러가지를 이것저것 해봤는데도 안 되어서 참 답답합니다.

한가지 신기한 사실은 expressapp.get내에서 실행할 때는 된다는 점입니다. 예를 들어 코드가 아래와 같다고 하면

//1번 코드
app.get('/', (req, res) => {
    res.header("Access-Control-Allow-Origin", "*")
    DBFunction('arg')
        .then(result => {
            console.log(result)
            res.send(result);
        })
})
//2번 코드
function myFunction() {
    DBFunction('arg')
        .then(result => {
            console.log(result)
            return;
        })
}

myFunction()

1번 코드는 되는데 2번 코드는 안 된다는 점입니다... 무엇이 문제인지 전혀 모르겠습니다. 알려주시면 감사하겠습니다 😭
이것 저것 다 해봐서 확실친 않은데 우선 참고한 자료는 다음과 같습니다.
https://islibrary.tistory.com/49
https://neos518.tistory.com/86
https://stackoverflow.com/questions/66591333/change-mysql-authentication-plugin-to-caching-sha2-password
무엇이 문제일까요 도대체ㅠㅠ


불러오는 중...