1

I have 3 Domain names hosted with Godaddy, They all point at the same server hosting my angular 2 app, Is there a way to check the header of the request to determine which of the 3 domains the user is coming from?

1
  • by header what you refer to? Commented May 4, 2017 at 14:06

1 Answer 1

1

Your request is out when your Angular application is starting. So you can't parse your headers here.

I suggest you to prefer a request param that you add in your Godaddy hosted apps request, and then parse it in an Angular component with @angular/router like this :

import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, OnDestroy, Component} from '@angular/core';

@Component({...})
export class YourComponent implements OnInit {

  constructor(private activatedRoute: ActivatedRoute) {}

  ngOnInit() {
    this.activatedRoute.params.subscribe((params: Params) => {
        let origin= params['origin'];
        console.log(origin);
      });
  }

}

Alternatively, you could parse the request param with a pure Javascript on page loading (location.search...).

If you cannot edit the Godaddy hosted apps requests, you will have to configure a reverse proxy on the server which serve your Angular app.

Sign up to request clarification or add additional context in comments.

1 Comment

Exactly what I was looking for, Thank you Karbos!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.