带角度的动态子域

Saa*_*faq 4 subdomain angular-routing angularfire angular

我正在使用角

对于我们的项目,我们需要对带有子域的 URL 提供多租户支持。

我们有类似于 Slack 的产品,我们的每个租户(客户)都有自己独立的数据库,因此我们希望他通过以下方式访问我们的产品:

client1.myproject.com
client2.myproject.com
client3.myproject.com
Run Code Online (Sandbox Code Playgroud)

等等。如何在 Angular 中做到这一点?我们知道角度路由只能改变路径而不是域。它甚至根本不支持吗?

谢谢!

PS:这是对我之前没有问过的问题的重新提问。

小智 5

To test on development environment you need to do some settings in your host file(C:\Windows\System32\drivers\etc\hosts). You can add list of domains in it that will pointed to your localhost & serve your application.

ng serve --host client1.myproject.com --port 4200 --open
Run Code Online (Sandbox Code Playgroud)


小智 -2

Angular 的默认模式路由是http://example.com/client1。由于框架逻辑(或者业务模型,就像你想说的那样),你的请求是不可能实现的。