Skip to content

Instantly share code, notes, and snippets.

@asmyk
Created July 2, 2018 17:55
Show Gist options
  • Save asmyk/de5dc7129fda36996f6a7760a563165e to your computer and use it in GitHub Desktop.
Save asmyk/de5dc7129fda36996f6a7760a563165e to your computer and use it in GitHub Desktop.
export class UrlInterceptor implements HttpInterceptor {
constructor(private configService: ConfigService) { }
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpEvent<any>> {
// get API url depending on actual enviroment(prod, local etc)
const api_url = this.configService.getApiUrl();
// concat method name with API url
const request_url = api_url + req.url;
const intercepted = req.clone({ url: request_url });
return next.handle(intercepted);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment