상황)
axios.get('http://localhost:5000')
axios.post('http://localhost:5000','data')
axios.get('http://localhost:5000')
axios.post('http://localhost:5000','data')
axios.get('http://localhost:5000')
axios.post('http://localhost:5000','data')
axios.get('http://localhost:5000')
axios.post('http://localhost:5000','data')
axios.get('http://localhost:5000')
axios.post('http://localhost:5000','data')
생활코딩식 상상력을 발휘하여 위와 같은 요청이 1억개가 있다고 하자
그럼 당연히 엄청난 중복이 발생할 것이다
아래와 같이 axios.defaults.baseURL에 원하는 prefix값을 설정해주면 중복이 줄어들 수 있다
axios.defaults.baseURL = 'http://localhost:5000'
axios.get('/')
axios.post('/','data')
axios.get('/')
axios.post('/','data')
axios.get('/')
axios.post('/','data')
axios.get('/')
axios.post('/','data')
axios.get('/')
axios.post('/','data')
+) chatgpt는 신이다 (아래 방법은 위와 조금 다름)
'Node.js' 카테고리의 다른 글
cors 'Access-Control-Allow-Credentials' 헤더 설정 시 주의할 점 (0) | 2023.03.25 |
---|---|
cors를 설정해야 하는 이유 (sop의 존재이유) (0) | 2023.03.22 |
nodejs에서 자주 쓰는 미들웨어 모듈 (0) | 2023.02.23 |
미들웨어 확장법 (0) | 2023.02.23 |
Nodejs에 대한 오해 (0) | 2023.02.17 |