How to have one domain serving frontend and backend? - heroku

Let's say I purchase the domain: "www.myapp.com".
I'm planning to run a headless CMS on heroku and a Vue js frontend on netlify.
How can I use the same domain for both apps?
I would like something like this:
Backend: "backoffice.myapp.com"
Frontend: "www.myapp.com"
Is it possible with 1 domain? How do I approach this?

In your domain provider panel you create backoffice.myapp.com subdomain and point CNAME record to heroku. And you set a CNAME record for www.myapp.com to netifly.
Instructions:
Netifly
Heroku

Related

How to config Laravel API and NuxtJS in same domain

I have a domain like domain.com
I have a Web API (Laravel) at domain.com/api
I have landing page (Laravel) at domain.com/
I have blog (Laravel) at domain.com/blog
I have Web App (NuxtJS) at app.domain.com
I want to merge domain.com and app.domain.com into one. What do I have to do to achieve that?
My server uses Nginx and Centos 7. Thank you so much for reading my question!

Subdomain reroute to domain

I have created a web app using Laravel 8 and is hosted on Server A using domain name 'myapp.com'. I have applied a wildcard subdomain eg: 'myweb1.myapp.com' and 'myweb2.myapp.com' for one of the app features.
I then purchased a domain 'myweb1.com' from Server B which I intends to reroute it to 'myweb1.myapp.com'. How do I achieve this?
So, when 'myweb1.myapp.com' is entered the URL will reroute to 'myweb1.com'. And 'myweb1.myapp.com/product' will be 'myweb1.com/product'.
Do I need to change the nameservers for 'myweb1.com'? Do I need to change .htaccess for it? What if I only purchased a domain without a hosting which I can't edit .htaccess? Can I achieve this? And are there any specific term for I want to do?
you can do it with reverse proxy.
if your web server is nginx: https://stackoverflow.com/a/14352958/5987259
if your web server is apache: https://stackoverflow.com/a/52286695/5987259

How can I have my nextjs app and my strapi CMS have the same domain and subdomain?

I have 2 apps on my heroku, one for my nextjs page and another for my strapi headless CMS. Right now I have a subdomain for strapi, and the root domain for nextjs.
I use heroku, my current situation is subdomain.example.com/admin for strapi and example.com for nextjs.
What I wanted was example.com for nextjs and example.com/admin for strapi.
Thanks

Heroku custom domain with Godaddy

I have a heroku app set up on a .app TLD, and a custom domain through GoDaddy.
What I would like is to have something like this:
myapp.example.com resolves to my app, and does not redirect.
What I am currently experiencing is:
myapp.example.com redirects (with a 307) to my-example-app.herokuapp.com
What I have done:
Following the Heroku guide for custom domains, I've done heroku domains:add myapp.example.com -a my-example-app and also added a cname to though the Godaddy UI for my domain.
CNAME myapp some-heroku-dns-somehash.herokudns.com
Any help, advice or pointers would be appreciated.
Edit: The 307 redirect is just due to the app redirecting to /sign-in. The issue that I am trying to resolve is using the custom domain, and not the heroku domain.
The 307 redirect is just due to the app redirecting to /sign-in.
This causes me to think that your application thinks it should build URLs using the Heroku domain instead of the custom domain.
Does your application have a place where its domain is configured? You might just need to update that setting so it can build own URLs using the proper domain.

How to point subdomain to a Heroku app, and root domain to another Heroku app?

I'm having trouble with routing a subdomain to a Wordpress blog hosted on Heroku, and the root domain to another Heroku app.
If I have purchased a domain called cheese.com on NameCheap and I'd like to route a subdomain like blog.cheese.com how could I do this on Heroku?
What type of setting would I need to place on each Heroku application?
I'm not sure of exact directions for NameCheap but the general way to redirect a subdomain to the Heroku app would be to add a CNAME record to the subdomain. To redirect the root domain you will need to set a CNAME like functionality at the zone apex.
Subdomain
blog.cheese.com would have a CNAME record pointing to myblog.herokuapp.com, you may also want to create a CNAME record for www.blog.cheese.com.
An example record could be:
Name: blog.cheese.com
TTL: 14400
Type: CNAME
Address: myblog.herokuapp.com
Once both CNAME records are set up you will need to tell heroku to point the domain to your app.
heroku domains:add --app myblog blog.cheese.com
If you do this for both your subdomains they should now point to your Heroku apps.
Root Domain
To point the root domain you will need to set a couple of records
Host Name: #
URL: http://www.cheese.com
Record Type: URL Redirect
Host Name: www
URL: mymainpage.herokuapp.com
Record Type: CNAME (alias)
Once both records are setup just call the command below via Heroku to point your domains to it.
heroku domains:add --app mymainpage.herokuapp.com cheese.com
Here are a couple of places to look for extra information.
Point namecheap domain to Heroku
Custom Domains | Heroku Dev Center
You will have to add the custom domain to your heroku app - https://devcenter.heroku.com/articles/custom-domains -
After setting the necessary DNS, you can add the wildcards

Resources