I have an angular app with a firebase backend. My app lets people create profile pages. I want to let people point their domain to their profile page. I don't even know where to start or what to search for. How would one let users point their custom domain to a specific route in a client-side angular app?
How would one let a user point their custom domain to a specific route in a client side Angular app?
-
What do you mean exactly by point their custom domain? Can you add a flow to make it clearer? – yazantahhan Nov 01 '19 at 13:12
-
i want to redirect https://example.com/user/userId to user created custom domain example https://userDomain.com – Nov 01 '19 at 13:17
1 Answers
I would create each user's profile page based on their user id, or some form of identifier you have for them.
You can parameterize the route so that angular-app.com/users/123
points to user 123's profile. You can set this up with the :variable
syntax in the route name of your angular router. In the UserProfilePage, you would then grab the parameter from the route to show that user's profile.'
The route in your app's router would look like:
{
path: "users/:user_id",
component: UserProfilePage
}
And on the UserProfilePage you would use it like:
constructor(private activeRoute: ActivatedRoute){}
ngOnInit(){
this.user_id = this.activeRoute.snapshot.params["user_id"];
// Do stuff with user id after this point to show their profile
}
Check out the angular router documentation here, and maybe search the page for "parameter" to see more info about using route parameters.
If you want users to be able to redirect their site to these, pages, they would simply set up redirects for their websites to go to angular-app.com/users/theirUserId
.
To redirect from this page TO each user's own website, I would grab the user's info from your database or API during ngOnInit, then change the browser location to their URL that you pull from their user info.

- 817
- 1
- 10
- 25
-
I want to let people create custom domain for their profile pages and host it using firebase hosting. – Nov 01 '19 at 13:38
-
https://www.pitchero.com/user-guides/club-website/getting-started/domain-names/how-to-get-a-custom-domain – Nov 01 '19 at 13:45
-
https://www.pitchero.com/user-guides/club-website/getting-started/domain-names/club-custom-domains – Nov 01 '19 at 13:47
-
-
A custom domain would cost them money to set up, so they'd have to set it up themselves. Firebase allows you to create subdomains for free I think, but I don't think that firebase offers a way to do that programmatically. If they set up their own domain, then save that as part of their profile info, changing the browser url via javascript as I mentioned would still work. – Paul Nov 01 '19 at 13:54