Last active
May 11, 2021 13:05
-
-
Save dancornilov/f7d53840992be53b4b14185dfc46659a to your computer and use it in GitHub Desktop.
Environment HttpInterceptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http'; | |
import {Observable} from 'rxjs/Observable'; | |
import {environment} from '../../../environments/environment'; | |
@Injectable() | |
export class EnvironmentInterceptorService implements HttpInterceptor { | |
constructor() { | |
} | |
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
const update = {} as any; | |
update.url = `${environment.serverName}/${req.url}`; | |
return next.handle(req.clone(update)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment