Hi all, this is Adi, again with another Laravel post. In one of my recent projects, I had to set up specific subdomain routing within the same Laravel application. This was something new to me because on most projects, I just work with one domain and everything is accessed /
after it. I am going to share with you how I solved it. I hope it gives you some ideas when you are faced to do this too. Let’s get started.
What Was My Need?
First, let’s explore my requirements for this project. My client wanted to access the admin portal from the admin.myapp.com
domain, the marketing website from myapp.com
, and the API from api.myapp.com
. As you can see it defers from Laravel’s defaults. By default, Laravel exposes API routes in myapp.com/api
url and everything else in myapp.com/
domain.
Hi all, this is Adi, again with another Laravel post. In one of my recent projects, I had to set up specific subdomain routing within the same Laravel application. This was something new to me because on most projects, I just work with one domain and everything is accessed / after it. I am going to share with you how I solved it. I hope it gives you some ideas when you are faced to do this too. Let’s get started.
What Was My Need?
First, let’s explore my requirements for this project. My client wanted to access the admin portal from the admin.myapp.com domain, the marketing website from myapp.com, and the API from api.myapp.com. As you can see it defers from Laravel’s defaults. By default, Laravel exposes API routes in myapp.com/api url and everything else in myapp.com/ domain. […]