I also ran into this while working on a new centralized dev environment for my team. I was already using absolute URL's, and in my current configuration, using a domain name would not work due to DNS/load balancer not being pointed to the new server.
I have an angular application running on a node container and a PHP container serving my backend. Tying all of this together, I have an nginx container (with no exposed ports) hooked up to traefik - where basically everything requesting /api
is routed to my PHP container. All SSR requests need to be set to my proxy, while client side requests to the API need to use the absolute url.
I was able to solve this by creating an HTTP interceptor to rewrite requests to communicate to my nginx container (named proxy
) in the docker compose project.
@Injectable()
export class ServerDockerInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const apiReq = req.clone({ url: `http://proxy${req.url}` });
return next.handle(apiReq);
}
}
This interceptor was added to my AppServerModule.