0

I'm using express-subdomain for handling subdomains of my site.

I have these two: www.mysite.com and blog.mysite.com and I want to handle their corresponding requests separately so that they don't have access to each other's routers.

//index.js
app.use(subdomain("blog", blogRouter)); // Handle all requests from the blog
app.use("/api", mainRouter);            // Handle all requests from the main site

They both work, but the problem is when I'm in my blog and I run blog.mysite.com/api I still have access to the /api response of the main site. How can I prevent it?

Also, the mainRouter looks like this:

// mainRouter.js
const router = express.Router();

router.use("/some-path", somePathHandler);
router.use("/some-other-path", someOtherPathHandler);

module.exports = router;
HTB
  • 413
  • 1
  • 9
  • 22

0 Answers0