node.js - How to assign a subdomain to some routes? -
i'm writing application in node.js , express, application has frontend written in jade , less , writing restful api create, read, update , delete data in database (mongodb)
for application have domain: example.com, , want frontend can accessed example.com , secondly want api accessible api.example.com
how can routes subdomain api respond?
ps. if not relevant, entire application written using kraken.js (paypal)
what i'd recommend have 2 separate projects entirely: 1 web front-end, , 1 api service. keep these 2 projects in separate git repositories (or whatever form of version control use), , give each project it's own database / web servers / etc.
once you've got 2 projects deployed 2 (or more) servers, can configure dns point services pretty easily.
for main site, you'll want create dns record points public ip address of web server hosts website project.
for api site, you'll want create dns cname record points web server hosting api project.
if you're using service heroku, process simpler: can use cnames , simplify process bit.
Comments
Post a Comment