21 lines
504 B
Markdown
21 lines
504 B
Markdown
```bash
|
|
npm install express
|
|
npm isntall http-proxy-middleware
|
|
```
|
|
|
|
``` js
|
|
const express = require('express');
|
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
|
|
const app = express();
|
|
const PORT = 9005;
|
|
|
|
// "/api"로 시작하는 모든 요청을 다른 서버로 포워딩합니다.
|
|
app.use('*', createProxyMiddleware({ target: 'http://192.168.101.67:8080', changeOrigin: true }));
|
|
|
|
// 서버 시작
|
|
app.listen(PORT, () => {
|
|
console.log(`Server is running on port ${PORT}`);
|
|
});
|
|
```
|