首先安装express gateway:
npm install -g express-gateway
找一个干净的目录创建一个 EG 网关项目:
eg gateway create
安装完成后,进入安装目录,修改gateway.config.yml,增加配置
增加serviceEndpoints:
serviceEndpoints:
local-service:
url:'http://127.0.0.1:8888'
增加apiEndpoints:
client-demo:
paths:["/api","/api/*"]
增加pipelines:
pipelines:
local-pipeline:
apiEndpoints:
- client-demo
policies:
- proxy:
- action:
serviceEndpoint: local-service
changeOrigin: true
使用npm start运行
网友评论