好吧,我需要创建一个端点,可以使用 express-gateway 创建一个用户,其中有 2 个端口正在运行。
- 网关 http 服务器监听 :::8181
- 管理员 http 服务器正在监听 127.0.0.1:9876
我可以创建一个用户,将我的信息发送到:
http://127.0.0.1:9876/users
我不能使用这个我的端点,因为我的前端有其他配置,所以在我的前端将我的创建用户信息发送到:
http://localhost:8181/api/user/create
现在我需要将我的信息发送到此http://localhost:8181/api/user/create
并将网关中的内部重定向到此http://127.0.0.1:9876/users
,我尝试了一些方法,但只是有错误的网关或找不到。我称这个端点为用户,所以这是脚本。
http:
port: 8181
admin:
port: 9876
host: localhost
apiEndpoints:
events:
host: localhost
paths: ["/api/events*", "/swagger*"]
methods: ["GET", "PATCH"]
users:
host: localhost
paths: "/api/user/create*"
url: "http://localhost:9876"
methods: ["POST", "OPTIONS"]
eventsCreate:
host: localhost
paths: "/api/events*"
methods: ["POST", "PUT", "OPTIONS"]
auth:
host: localhost
paths: "/api/auth*"
methods: ["POST", "GET", "OPTIONS"]
serviceEndpoints:
auth:
url: "http://localhost:59868"
events:
url: "http://localhost:5000"
users:
url: "http://localhost:9876"
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
- jwt
- request-transformer
pipelines:
authPipeline:
apiEndpoints:
- auth
policies:
- cors:
- log:
action:
message: "auth ${req.method}"
- proxy:
action:
serviceEndpoint: auth
changeOrigin: true
eventsPipeline:
apiEndpoints:
- events
policies:
- cors:
- log:
action:
message: "events ${req.method}"
- proxy:
action:
serviceEndpoint: events
changeOrigin: true
usersPipeline:
apiEndpoints:
- users
policies:
- cors:
- log:
action:
message: "users ${req.method}"
- proxy:
action:
serviceEndpoint: users
changeOrigin: true
userPipeline:
apiEndpoints:
- events
policies:
- cors:
- log:
action:
message: "events ${req.method}"
- proxy:
action:
serviceEndpoint: events
changeOrigin: true
eventsCreatePipeline:
apiEndpoints:
- eventsCreate
policies:
- cors:
- log:
action:
message: "events ${req.method}"
- jwt:
action:
secretOrPublicKey: "MORTADELAIsMyPassion321"
checkCredentialExistence: false
- proxy:
action:
serviceEndpoint: events
changeOrigin: true