How to direct a domain to subdomain (Next.js + ZEIT) - subdomain

I have a web platform where each user has a profile, eg. domain.com/user/morgan.
I'm using Next.js, and by detecting either req.headers.host or window.location.host on the index page, I can serve up that same profile page on morgan.domain.com.
Now I want to allow users to choose their own domain name, and have it point to their profile page. I've managed to point mycustomdomain.com to domain.com, but I can't work out how to point it to morgan.domain.com.
Or perhaps it is connecting properly to morgan.domain.com but my Next.js code (which detects literally from the URL what the subdomain is) cannot work out that it's a subdomain.
In any case, is it possible with ZEIT and Next.js, to have mycustomdomain.com point to morgan.domain.com and have the page realise that this is a subdomain, and it should serve the user profile page and not the domain.com homepage?

Related

How do I persist custom subdomains in firebase hosting without redirects

I've set up my custom domain with firebase hosting using their CNAME and A record details. Visiting http://sub.example.com redirects to https://example.com (not what I wanted)
I want to persist my subdomain (https://sub.example.com) in the address bar without the 301 redirect to (https://example.com) that I'm currently getting. Is this possible to set up this behavior within firebase hosting itself? I'd also like to point this sub domain to a certain html file/directory that I configure.

Serving local file:/// links and AppCache

I'm making a webapp for members of my caving club to search through and view cave survey note PDFs. It works fine, and I got the AppCache working for the web version of it.
However, since the PDFs are quite large and slow to download, and many members have the PDFs on their local machines from the same SVN the website gets them from, it would be ideal for them to be able to use a page with links to a local SVN folder of their choosing.
The design goals:
The site displays links to PDF files on the local filesystem
Whenever I add features to the site, users get them automatically the next time they open the page and they're connected to the internet
But after the first time they open the page, the site works offline.
Sadly web browsers don't appear to support this useful combination of design goals at once.
I can satisfy #1 by having users download a copy of the site, add their local SVN path in a JS, and open their local copy in the browser, so that file:/// links work.
I can satisfy #2 by having absolute links to JS bundles on the server.
I can satisfy #3 by using the AppCache.
I thought I could get clever by having the copy of the page on the local file system have <html manifest="https://myserver.com/myapp.appcache">, but unfortunately Chrome doesn't seem to allow a local file to use an app cache manifest hosted on a server, for seemingly no good reason to me.
Does anyone know of another way I could satisfy all 3 goals?
Perhaps there's some simple program/config I could give my friends that would intercept web requests to https://myserver.com/some/folder and instead serve them out of a folder on their local file system?
Andy,
I know this post is a bit old but came across it looking for something else related to AppCache. My understanding it that the html page and the manifest must reside in the same domain for it to work. So I think you need to modify your design:
Create a JavaScript function that acts as a setting for the user to enter the path to their local copy of the PDF's. Store this information in localstorage.
Create a html template page for the document links.
Create a JavaScript function that populates the html template page with any documents and links the user enters.
This way, the users visit your application online and it uses appcache to store itself and the JS files for offline use. To access the PDF's, the user clicks a settings button that launches a page to collect path information and saves the information in localstorage. The users can then access the template page which will populate with the documents they entered.
Here is a good intro to localstorage: [http://www.smashingmagazine.com/2010/10/local-storage-and-how-to-use-it/]

OpenShift custom domain not working for internal pages

I purchased a domain (iwantmydomain) and it points to an openshift application, main page loads and status bar shows the custom domain, but when I click a post then it shows the openshift url.
www.alrazylabs.com
I tried to follow:
https://www.openshift.com/blogs/domain-names-and-ssl-in-the-openshift-web-console
At the moment it looks like everything is working fine. Usually if a wordpress blog's links are pointing to the wrong url (the .rhcloud.com one) it means that you did not change the url in the wordpress admin to your custom domain.

'Cloaked' domain forwarding not working as expected

I've registered a domain with www.domain101.com. We'll call it www.example.com. I used their 'cloaked forwarding' option on my heroku app, which we'll call example.herokuapp.com. If I want to navigate to the posts index page, I would go to example.herokuapp.com/posts, of course; however, when I try this with my cloaked domain - www.example.com/posts - it takes me to the landing page. What's more, the url is constantly set to 'www.example.com' and the title of each page is "EXAMPLE.COM". I can click buttons on the pages and navigate through my website, but the url remains strictly at 'www.example.com'.
I used the forwarding option available on the website. What else should I be doing?
Domain cloaking uses a frame to make visitors' browsers show the cloaking domain in the location bar, while having the actual content hosted somewhere else. That's why the location bar never changes when you navigate around the site; and it isn't surprising that domain101's cloaking implementation doesn't forward path information to your Heroku app.
What you should do instead is configure a DNS server to direct traffic for your domain directly to Heroku. The simplest option for that on Heroku is the Zerigo DNS Add-on, which is free if you're hosting a single domain. You can also find DNS servers provided by lots of other people if you prefer.
Once you've configured a DNS server, you also need to tell your registrar that the DNS server you chose is the primary DNS for your domain. The way to do that varies between registrars, so you should check domain101's documentation for details.

How do I move a site from one url to another?

I have an ASP.NET web application hosted on DiscountASP.NET with its domain name registered on GoDaddy. This site is working perfectly and runs great, but I hate the domain name.
So now, I decide to purchase a domain name I like better. How do I set it up so that this domain name runs the same web app as my original application, but using the new domain name instead of the old one (i.e. I don't want to redirect to the old url, I want everything to work under the new url)?
This should be quite simple. Go to the host/registrar of your new domain and point it to the same ip addresses that the godaddy url points to.
You can have the old url and new url coexist. The DNS servers just map to the the physical IP your app is hosted on.
If you've been naughty and use absolute urls/directories in your app, you will have to rewrite some code. All the while reciting the mantra... that's why I should have used relative references...
Either move the application files over and create a redirect from the old URL to the new, or set up a rewrite under the new URL to transparently pass requests to the existing one.