Closed alvarosabu closed 7 years ago
I find out a solution, it haves to do with the ServerUrlInterceptor itself
export class ServerURLInterceptor implements Interceptor {
public interceptBefore(request: InterceptedRequest): InterceptedRequest {
/* let url = localStorage.getItem('restServerUrl') || ''; */
let url = 'http://localhost:5678/api';
request.url = url + request.url;
request.options.url = url + request.options.url;
if (request.options.method === RequestMethod.Post) {
request.options.headers.set('Content-Type', 'application/json');
}
return request;
}
}
It seems you have to change both request.url
and request.option.url
for it to work, I will let it here if someone needs it, now is working.
Hi Victor,
I having an issue trying to do a Server Url Interceptor to prepend the Api url
(http://localhost:5678/api)
to every Http request, I debug and its passing trough the Interceptor but the Post request use the actual dev server url (http://localhost:7682) where the app is running so it means that is not adding the new url created in the interceptor to the post request.Here is my setup:
Login.module.ts
ServerUrlInterceptor.ts
Auth.service.ts