title: CORS Angular 2 interceptor
body: <p>When i ask to <strong>"api/authenticate"</strong> or <strong>"api/account"</strong>, interceptor sends me to <a href="http://localhost:8443" rel="nofollow noreferrer">http://localhost:8443</a> (<a href="http://localhost:8443/api/authenticate" rel="nofollow noreferrer">http://localhost:8443/api/authenticate</a> for example), but in other cases (<strong>"api/plan-reports"</strong> for example) i need to ask to <a href="http://localhost:8443/hermessm/api/plan-reports" rel="nofollow noreferrer">http://localhost:8443/hermessm/api/plan-reports</a>.<br>
   So i have the error below. </p>
  
  <p>Does anyone know how to fix it?
  It seems to me the error from interceptor. Please, help me!</p>
  
  <h2>interceptor.ts</h2>
  
  <pre><code>request(url: string | Request, options?: RequestOptionsArgs): Observable&lt;Response&gt; {
      return this.intercept(super.request(url, this.getRequestOptionArgs(options)));
  }
  
  get(url: string, options?: RequestOptionsArgs): Observable&lt;Response&gt; {
      url = this.updateUrl(url);
      return super.get(url, this.getRequestOptionArgs(options));
  }
  
  post(url: string, body: string, options?: RequestOptionsArgs): Observable&lt;Response&gt; {
      url = this.updateUrl(url);
      return super.post(url, body, this.getRequestOptionArgs(options));
  }
  
  put(url: string, body: string, options?: RequestOptionsArgs): Observable&lt;Response&gt; {
      url = this.updateUrl(url);
      return super.put(url, body, this.getRequestOptionArgs(options));
  }
  
  delete(url: string, options?: RequestOptionsArgs): Observable&lt;Response&gt; {
      url = this.updateUrl(url);
      return super.delete(url, this.getRequestOptionArgs(options));
  }
  
  getRequestOptionArgs(options?: RequestOptionsArgs): RequestOptionsArgs {
      if (!options) {
          options = new RequestOptions();
      }
      if (!options.headers) {
          options.headers = new Headers();
      }
      options.withCredentials = true;
      return !this.firstInterceptor ? options : this.firstInterceptor.processRequestInterception(options);
  }
  
  
  intercept(observable: Observable&lt;Response&gt;): Observable&lt;Response&gt; {
      return !this.firstInterceptor ? observable : this.firstInterceptor.processResponseInterception(observable);
  }
  
  private updateUrl(req: string) {
      if (req.indexOf("api/authenticate") !== -1 || req.indexOf("api/account") !== -1) {
          console.log(environment.gataway + '/' + req)
          return environment.gataway + '/' + req;
      }
      else if (req.indexOf("api/") !== -1) {
              return environment.gataway + '/hermessm/' + req;
      }
      else {
          return req;
      }
  }
  </code></pre>
  
  <p>}</p>