Skip to content

Instantly share code, notes, and snippets.

@bbogdanov
Last active November 1, 2017 08:42
Show Gist options
  • Save bbogdanov/aa9f0d5c60893199ed5e60cddeaf22ce to your computer and use it in GitHub Desktop.
Save bbogdanov/aa9f0d5c60893199ed5e60cddeaf22ce to your computer and use it in GitHub Desktop.
Server Location Angular Interceptor
import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class ServerLocationInterceptor implements HttpInterceptor {
public intercept(req: HttpRequest<any>,
next: HttpHandler): Observable<HttpEvent<any>> {
const clonedRequest: HttpRequest<any> = req.clone({
url: 'https://someurl.example/'
});
return next.handle(clonedRequest);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment