Closed benjsicam closed 6 years ago
Ok. I think it has something to do with how the routes are ordered upon declaration. This fixed it for me so anyone who bumps into this issue shouldn't spend lots of time debugging this.
const { ServiceBroker } = require('moleculer')
const ApiService = require('moleculer-web')
const broker = new ServiceBroker()
broker.createService({
name: 'api-gateway',
mixins: [
ApiService
],
settings: {
routes: [{
path: '/healthz',
mappingPolicy: 'restrict',
aliases: {
'GET /': '$node.health'
}
}, {
path: '/',
mappingPolicy: 'restrict',
aliases: {
'GET /': '$node.health'
}
}]
}
})
broker.start()
Declare the root last.
Yes, I will add this info into docs
Code to reproduce:
Expected Result:
Both GET / and GET /healthz should the node health response
Actual Result:
GET / will work and respond with the node health GET /healthz returns an HTTP 404 Error