작업 상태

- window 10 host/ virtualbox 7.0 에 guest ubuntu 22 버전을 설치후에 처음 gnome-terminal을 실행했습니다.

- gnome-terminal실행이 안됩니다.
 

처리

- 원인은 모르겠습니다. 

- 아래 글에서 말한것처럼 LANG="en_US.UTF-8"로 수정후 재시작하니 동작합니다.

- 수정전에는  LANG="en_US" 였습니다.

 

cat /etc/default/locale

참고

Problem with "gnome-terminal" on Gnome 3.12.2 - Ask Ubuntu

 

Problem with "gnome-terminal" on Gnome 3.12.2

I have Ubuntu-Gnome 14.04 (Gnome 3.12.2). When I try to run gnome-terminal by following command : $ gnome-terminal Error constructing proxy for org.gnome.Terminal: /org/gnome/Terminal/Factory0: ...

askubuntu.com

 

작업 상태

- SSR 작업 중 https로 데이터를 얻어오는 일이 있어서 axios쪽에 https 인증 무시를 설정한 후 브라우저에서 계속 보였습니다.
 
에러 메시지 

 

Uncaught TypeError: https.Agent is not a constructor 

Uncaught TypeError: https.Agent is not a constructor
이미지를 설명하는중@.@

const agent = new https.Agent({    //<-- 에러 발생 부분
  rejectUnauthorized: false
});

//서버와 통신하다: communicate with the server
const cwts = axios.create({
  baseURL: `${apiUrl}/api`,
  timeout: 5000,
  httpsAgent: agent,
  headers: {
    'Content-Type': 'application/json',
  },
});

- 코드는 특별히 문제가 없었습니다.

- https.Agent는 HTTP(S) 연결을 관리하고 재사용하는 HTTP(S) 에이전트 객체의 인스턴스를 생성하는 생성자 함수입니다. 일반적으로 Node.js에서 HTTPS 서버에 요청을 보낼 때 사용됩니다.

 

원인

- 원인은 이 부분의 코드가 문제가 아니었습니다.

- 상단 코드가 server용, client용 공용 util으로 사용되는 부분이어서 문제가 되는것이었습니다.

- 변환, 배포후 server용은 node에서 동작 client용은 브라우저에서 동작하게 되는 부분입니다.

- 이 부분에서 https.Agent가 브라우저에서 동작하면서 발생하는 문제였습니다.

처리

- 개발환경이 vite, react tsx,ssr 작업 중이어서 vite환경변수를 이용해서 설정을 분리했습니다.

const ssr :boolean = import.meta.env.SSR;

let configx = {
  baseURL: `${apiUrl}/api`,
  timeout: 1000*10,
  // httpsAgent: agent,
  headers: {
    'Content-Type': 'application/json',
  },
}

if( ssr ){//is server
  const agent = new https.Agent({  
    rejectUnauthorized: false
  });

  configx = Object.assign({}, configx, { httpsAgent: agent });
}
 
const cwts = axios.create(configx);

클라이언트 측 변환코드

let configx = {
  baseURL: `${apiUrl}/api`,
  timeout: 1e3 * 10,
  // httpsAgent: agent,
  headers: {
    "Content-Type": "application/json"
  }
};
const cwts$1 = axios$1.create(configx);

서버측 변환코드

let configx = {
  baseURL: `${apiUrl}/api`,
  timeout: 1e3 * 10,
  // httpsAgent: agent,
  headers: {
    "Content-Type": "application/json"
  }
};
{
  const agent = new https.Agent({
    rejectUnauthorized: false
  });
  configx = Object.assign({}, configx, { httpsAgent: agent });
}
const cwts$1 = axios.create(configx);

 

참고

시작하기 | Vite (vitejs-kr.github.io)  vite

작업 상태

- List<> lists 의 내용의 값을 합하다가 나온 에러입니다.

 

Long totalCount = 0L;

for(Category cate: categorites){
    String name = cate.getName();
    Long count = 0L;
   
    try{
        count = countMap.get(name);
        if(count == null ) count = 0L;
    }catch(Exception e){ count = 0L;}

    totalCount += count;

    cate.setCount(count);
}

이런 형태를 함수형? 연산으로 변환하던중 나타났습니다.

        int totalCount = topicList.stream().mapToInt(Topic::getCount.intValue()).sum();


에러 메시지 

java.lang.Error: Unresolved compilation problem:
 The target type of this expression must be a functional interface

java.lang.Error: Unresolved compilation problem:
        The target type of this expression must be a functional interface

 

원인

public class Topic {
    @Transient Long count; 

이게 Long 형이어서 int형변환해서 계산하려던 중 발생했는데.

java 문법자체를 아직 잘 이해 못하겠습니다.


처리

// int totalCount = topicList.stream().mapToInt(Topic::getCount.intValue()).sum();

 

int totalCount = topicList.stream().mapToInt(topic -> topic.getCount().intValue()).sum();

참고

자바람다식

List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
IntStream intStream = list.stream().mapToInt(i -> i * i);

작업 상태

- 리액트에서 로그인 페이지 작업중 디자인 코드를 붙인 후에 발생했습니다.
 
에러 메시지 

Warning: Invalid DOM property `for`. Did you mean `htmlFor`?

Warning: Invalid DOM property `for`. Did you mean `htmlFor`?


원인
- React에서 JSX 코드를 작성할 때 발생하는 것으로, for와 같은 일부 DOM 속성은 JSX에서 사용할 때 이름이 다릅니다.

 

<label className="block" for="email">Email</label>
<input
    type="email"
    name="email"

 

처리

-  속성을 JSX에서 올바른 이름으로 작성하면 해결됩니다.

 

<label className="block" htmlFor="email">Email</label>
<input
    type="email"
    name="email"

참고

html   jsx
for htmlFor
tabindex tabIndex
ondblclick  onDoubleClick
onchange  onChange
class className

이 외에도 다양한 DOM 속성들이 있으며, JSX에서 사용할 때 이름이 다를 수 있습니다. 이러한 속성들의 이름은 일반적으로 camelCase로 작성됩니다.

+ Recent posts