New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to get location with universal #19
Comments
Currently not, but I'll have a look at this probably in the weekend. |
@theomathieubhvr, I am not totally aware of your specific case, but can't (and shouldn't?) the router handle that? |
@Gbuomprisco I'm trying to get the domain of the website I visit. I tried to do this |
Well, I can suggest you a simple workaround to retrieve that value using ngx-meta. There's the You can always access the contents of |
Ok sorry but I checked and appplicationUrl parameter is very much static. Maybe I haven't been clear, I will try to reexplain. Assuming I have a news website with two categories, Politics and Economics. I want to offer http://politics.website.com and http://economics.website.com as urls that my user can go to. These with ONE repository, yours. I want to know which user is on which website. Is there any way to do this ? Thanks :) |
OK i managed to do it ! I can make a Pull request if needed (but I think this is too specific). To sum up how I did, I created a custom OriginService for server (for browser I just set origin to window.location.origin). import { Injectable, Inject } from '@angular/core';
import { Request } from 'express';
import { REQUEST } from '@nguniversal/express-engine/tokens';
@Injectable()
export class OriginService {
public origin: string;
constructor(@Inject(REQUEST) private request: Request) {
this.origin = request.hostname;
}
} |
@theomathieubhvr I tried you method and I am able to get origin url but its giving an error on browser:
|
Have you created a OriginService for the browser too ? |
Any way to achieve this (get the express request object) with @ngx-universal/express-engine please ? |
Hey,
I'm submitting a ... (check one with "x")
What is the motivation / use case for changing the behavior?
I am creating a white label website on which the content shown is dependant from the url used by my users. I cannot use window.location as it is not available server side.
I would be pleased to help you implement this, but do you have any lead on how to do it ?
Thanks !!
PS: This topic seems interesting : http://stackoverflow.com/questions/43403649/how-to-get-full-base-url-including-server-port-and-protocol-in-angular-univer
The text was updated successfully, but these errors were encountered: