Using subdomains and CNAME records with Nuxt - dns

I know that I can set up a single Nuxt project which can serve multiple subdomains, like this:-
app1.example.com
app2.example.com
...
and have different content served on each subdomain based on the value of the subdomain.
The way this would work is that the Nuxt server would detect the value of the subdomain (app1, app2 etc.) and fetch data from the API (I am using a django rest framework backend) using that as a filter.
But is there a way of then mapping another domain to these subdomains so that the Nuxt server still knows how to fetch the right data from the API?
Something like this:-
myapp1.com -> app1.example.com
myapp2.com -> app2.example.com
I think that Heroku does something like this but it's hard to be certain - so it seems possible to me. But maybe there's another way to do this?

Related

Azure Application Gateway - single parent domain for multiple web applications

I am trying to setup one parent domain (app.mydomain.com) for front for 2 web apps in the backend.
mail.mydomain.com and module.mydomain.com. I have implement path based routing. I need to routing to work so
app.mydomain.com/* points module1.mydomain.com
app.mydomain.com/module2/* points module2.mydomain.com/
Routing seems to work, however when browsing module2, it css and js are not loaded and the site doesnt work. accessing module2 directly works normally.
Have you routing rules to change your URL?
Since you are using App Gateway, the URL that your backend is seeing is (app.mydomain.com) instead of module2.mydomain.com.
So, maybe when you’re using the AppGateway, your backend is looking for a CSS into the wrong path…

Dynamic subdomain creation in Node / Angular app without nginx

How can I create subdomains dynamically for each newly registered user in my Node / Angular app? I have come across several posts that suggest using an nginx server. Is there a way to accomplish the same thing but without using nginx?
Edit: I want the user to see userA.mydomain.com in their browser. I also want them later on (after registration) to navigate to such a URL and land on their own customized page.
In addition, I want the user to be able to map this subdomain userA.mydomain.com to their own custom subdomain such as course.userwebsite.com

Creating custom domain names for api

I have a web server using cpanel and I would like to use a custom domain on one folder for an api. So if I created a folder called api in the public_html folder then the path to that folder would be www.example.co.uk/api/(some php file). How could I change it so the folder would become a custom domain of api.example.co.uk/api/(some php file).
I have looked at a few options but don't really know the best way. I have tried to add a htaccsess file to the api folder and then create a rewrite rule to rewrite the www to api.
I also then looked at creating sub domains with the path to the api folder.
I have read that creating a A record on the server could work but I'm not quite sure how to do this. I know it can be done as most apis use some custom domain like facebooks graph api. (i.e https://graph.facebook.com/youtube/)
This will depend on if you have access to make DNS records for your root domain, example.co.uk. For example right now www. is a CNAME or A record (depends on how your web server is set up), that resolves to the address of your web server. If you made an identical record but named it api. (api. IN A ip-of-webserver), then api.example.co.uk would do the same thing that www.example.co.uk does. This is kind of pointless if they go to the same web server though, the /api/ part of the route makes it clear enough that the routes are for the api. What subdomains like facebook's are doing are pointing to a completely different application, and different web servers. For example, a company may have domains like mail.company.com, portal.company.com, sso.company.com, that all resolve to the address of different web servers for the different apps they have, but in this case it sounds like you are running one web server which is fine, you can have one web server be the api as well as serve the website.

How to manage sub-domains in node sites

I am creating my first MEAN2 app, but I stuck in mid. My site required one front-end (mysite.com) and one back-end(admin.mysite.com) to manage content. In future I would like to have a unique URL (*.mysite.com) for all the uses who will register at my site, for which there would not be a any directory in real. How could I acchieve it in a best way. To be more clear my requirement is -
mysite.com (original site)
admin.mysite.com (a sub-domain to be managed from same server.js file)
*.mysite.com (based on request host)
Note: I have created site using angular-cli are my structure is like below
-mysite(angular 4 app)
-admin(another angular 4 app)
-server.js
This problem is not specific to node.js. However, in order to setup a domain successfully for your web app, you'll need 2 things:
Web Server
This will manage for you virtual hostnames etc. I would advise you to look at setting up nginx as a reverse proxy in front of your node app.
Domain provider
This will actually allow you to publicly use the domain *.mysite.com. Then you will have to setup a DNS Record, generally an A record, to point at your server IP Address.
This is very high level :) but should be enough to get you started.
EDIT
If you want to test locally just setup nginx with a test server name to proxy_pass to your local nodejs app (i.e. http://localhost:3000) and create a host entry in your hosts file for that hostname.

Meteor app using subdomain for user accounts

I'm writing an app using Meteor for company inventory management. Each company will get their own subdomain, but essentially they'll all be using the same code & routes, the only difference being that depending on the subdomain the subscribe/publish/log-in will be unique to that subdomain.
For example, costco.myapp.com will only subscribe to the data that pertains only to costco.
My question would be how do I successfully create/implement subdomains using Meteor that use the exact same code/routes, but publish collection info only relevant to that subdomain?
I assume you want to know how to inspect the app url using Meteor.
Normally this would be accomplished with Meteor.absoluteUrl()
However, this uses the ROOT_URL environment variable, so you will not be able use it to differentiate different urls for the same app instance.
On the client use plain old window.location.hostname instead.

Resources