엄청나~~~~

less than 1 minute read

그,,,, 다른프로젝트 api를 호출하니까 401에러 unauthorized가 떴다.

원인은 브라우저에 저장된 쿠키 에서 session을 제대로 안가져가서…

그래서 오전내내 해메다가 팀장님께 여쭤봤는데,,

https://www.google.com/search?sxsrf=ALeKk024j-Ji6nD1mkiaGRFFJfeJAl1DCA%3A1609902050148&ei=4if1X67MCMXywQP6yaiQBA&q=ajax+%EC%BF%A0%ED%82%A4+%EC%A0%84%EC%86%A1&oq=ajax+%EC%BF%A0%ED%82%A4&gs_lcp=CgZwc3ktYWIQARgAMgIIADICCAAyAggAMgQIABAeOgQIIxAnUKDJBljc0QZguP8GaAJwAHgBgAHZA4gBxRCSAQUzLTIuM5gBAKABAaoBB2d3cy13aXrAAQE&sclient=psy-ab

이런 검색을 주셔따

그리고 해답이 있었따!!!!

  $.ajax({
        method: "GET",
        url: url,
        dataType:"json",
        crossDomain: true,
        xhrFields: {
          withCredentials: true
        },
        success: function(res){
          console.log("금융정보등록 res !!! ", res);
          if(res.success){
            console.log(res.resultData);
  // 					setRegInfoData(res.resultData);

            var html = "";
            $.each(res.resultData.list, function(index, value) {
              html += "<div class='form-group'><label>" + value.label + "</label>";
              html += "<input type='text' class='form-control' name='" + value.code + "' data-ax-path='" + value.code + "'>" +  + "</div>";
            });
            $("#regInfo").html(html);
          }else
            alert("오류 : "+ res.resultMsg)
        },
        error: function(error){
          console.log(error);
          alert("Http error : " + error.responseText);

        }
      });

crossDomain: true 해주고

  xhrFields: {
          withCredentials: true
        },

해줬다 너무신기해~~!!!

https://rocksea.tistory.com/286

이런 좋은 글이 있다~!!!!

내 경우에는 이미 api서버 설정에 Access-Control-Allow의 Credentials true 설정이 되어있었던듯!!

Updated: