regester subdomains with express-subdomain
Install package with npm or yarn
npm i express-subdomain
yarn add express-subdomain
Let's find out step by step
import subdomain from 'express-subdomain'
app.set('subdomain offset', 1)
subdomain offset
is the number of dot-separated parts of the host to remove to access subdomain.
For instance, if you use localhost, set it to 1. And if you use example.co.kr, set it to 3.
You can now re-register your sub-domain. Of course, the number of subdomains is not limited.
app.use(subdomain('api', api))
check out index.js