it is a good way to support host match in router definition:
// hosta.router.js
const routerA = new Router({
host: 'hosta.com' // only match if request host exactly equal `hosta.com`
});
router.get('/', (ctx, next) => {
// Response for hosta.com
});
// hostb.router.js
const routerB = new Router({
host: /^(.*\.)?hostb\.com$/ // match all subdomains of hostb.com, including hostb.com, www.hostb.com, etc.
});
router.get('/', (ctx, next) => {
// Response index for matched hosts
});
Checklist
[x] I have ensured my pull request is not behind the main or master branch of the original repository.
[x] I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
[x] I have written a commit message that passes commitlint linting.
[x] I have ensured that my code changes pass linting tests.
[ x I have ensured that my code changes pass unit tests.
[x] I have described my pull request and the reasons for code changes along with context if necessary.
If a server with many hosts and the same path in each host may different.
current version:
it is a good way to support host match in router definition:
Checklist