У меня есть приложение Angular 2.0, и недавно я добавил http-proxy-middleware со следующим bs-config.js:
var proxyMiddleware = require('http-proxy-middleware');
module.exports = {
server: {
port: 3000,
middleware: {
1: proxyMiddleware('/WorkLocation', {
target: 'http://localhost/Perform/Company/WorkLocation',
changeOrigin: false,
logLevel: 'debug'
}),
2: require('connect-history-api-fallback')({index: '/index.html', verbose: true})
}
}
};
Тогда у меня есть такой сервис:
export class WorkLocationsService extends BaseRestfulService<WorkLocationItemModel[]> {
private workLocationsServiceUrl: string = '/WorkLocation/EditList/111014/73442';
constructor(protected _http: Http) { super(_http) }
public getWorkLocations(): Observable<WorkLocationItemModel[]> {
return this.callApiEndPoint(null, this.workLocationsServiceUrl, HttpVerb.Get);
};
Когда я запускаю свое приложение через npm start
, оно вызывает настройки прокси-сервера bs-config.js, и я вижу следующий вывод:
[1] [HPM] GET /WorkLocation/EditList/111014/73442 -> http://localhost/Perform/Company/WorkLocation
[1] 17.02.09 20:44:09 404 GET /WorkLocation/EditList/111014/73442
Итак, похоже, что прокси-сервер HPM выполняет правильный перевод, но в строке ниже я получаю ошибку 404 в GET, исходящем от моего вызова WorkLocationService. Почему моя служба не может проходить через прокси-сервер, если он выглядит правильно настроенным? Я что-то упускаю?