问题
I have this code written in index.js
file. My api's are running successfully on the /
path. Now I need add a prefix to all my api's. I don't want to add one by one by editing each file. I need to do in one go.
composer((err, server) => {
if (err) throw err
server.initialize((errInit) => {
if (err) throw errInit
server.register({
register: require('hapi-cron'),
routes: { prefix: '/api' },
options: {
jobs: []
}
}, (err) => {
server.start(() => {
const env = process.env.NODE_ENV
const msg = `${env} server started at ${server.info.uri}`
server.log(['server', 'info'], msg)
if (_.includes(['sandbox', 'production'], env)) {
}
})
})
})
})
How Can I do this? Thank in advance!!!
来源:https://stackoverflow.com/questions/54516579/add-prefix-to-all-apis-in-hapi