Это можно реализовать с помощью Angular Http Intercepter
Добавить префикс http://api.dc -shop.com в каждом запросе.
Пример кода:
Напишите перехватчик запросов в вашем угловом приложении:
@Injectable()
export class RequestInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
let req_url = req.url
req.clone({url:`http://api.dc-shop.com/${req_url}`})
return next.handle(req);
}
}
И в вашем основном модуле:
export const httpInterceptorProviders = [
{provide: HTTP_INTERCEPTORS, useClass: RequestInterceptor, multi: true},
}
@NgModule({
providers: [...,httpInterceptorProviders]
})
Если выВы хотите настроить свой префикс url в другой среде:
Вы можете определить его в вашем environment.xx.ts
в /src/environments
И определить конфигурацию сборки в angular.json
....
"configurations": {
"api": {
....
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.api.ts"
}
]
}
....
}
...
А когда вы создаете свое приложение,
просто добавьте конфигурацию
ng build --configuration=api
Удачи!