Support the ongoing development of Laravel.io →
Architecture Laravel.io
Last updated 2 years ago.
0

You need to look into multi-tenancy solution. Google for it, and you will even find laravel packages for it.

You can also build it yourself; check your request for the domain name your app is accessed at; based on that, you can degine global scopes on your models to only fetch the objects from your database that should be available for site x, y or z...

Hope this helps

0

If the databases for all applications are different, and you might require CORS (Cross-Origin Resource Sharing) to access data from each into one place.

0

I've never personally understood why you would be bothered with CORS in such situations. If you just have the 4 domain names run the same code (point them to the same site as aliases), your code can be transparent, and all you need to do at the endpoint is check what domain name you have requested the call on to differentiate the data you want accessible (you could add a global scope for this, which is mostly what multi-tenant packages for laravel tend to do...)

0

Though I never got a chance to use multi-tenancy (which by the way is great) myself, but if all the code for all the 4 applications is in place already (may have different versions of Laravel running); wouldn't it be convenient to share data through CORS??

0

My point is - why would you need to ask site X for a resource on domain Y? My setup just always has all domain names point to the same code, so that any API available on domain X, is also available on domain Y and vice versa - ONE API, just published and available on multiple domains. On the server site, I just check what domain name the request came in through to scope down my data.

Does that make sense?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

dollar1990 dollar1990 Joined 23 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.