Answer the question
In order to leave comments, you need to log in
Handling multiple domains with one express application, is it possible?
The essence of the situation is this. There are several simple sites (for example, these are blogs / pages on different topics), they have a common database, and a common admin panel. For example, 10 blogs, each has its own domain (blog1.com, blog2.com, blog3.com, ...), and there is an admin panel (where we can upload articles, etc.), for example, it hangs on a sub-domain of some another domain (admin.my-root-blog.com). So, my-root-blog.com and admin.my-root-blog.com are broken into sub-applications using the subdomain module
//общие настройки
let app = express();
app.use(subdomain({base:host,removeWWW:true }));
app.engine("ejs",require("ejs-locals"));
app.set('view engine', 'ejs');
// и др.
// далее настройка основного приложения для домена my-root-blog.com
let admin = express();
// далее настройка admin
//Здесь подключаем роуты:
require("router/root")({app:app,admin:admin});
//под-приложение админ-панели вешаем на суб-домен, должно быть доступно по адресу: admin.my-root-blog.com
app.use("/subdomain/admin", admin);
//тут еще какие-то настройки ...
module.exports = app;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question