Node.js Angular cli代理配置不适用于本地主机?
正在尝试调用运行在Node.js Angular cli代理配置不适用于本地主机?,node.js,angular,typescript,http,Node.js,Angular,Typescript,Http,正在尝试调用运行在http://localhost:9001使用angular proxy config,但是我无法调用端点,知道我在下面的代码中实现了什么错误吗 服务台 import { Injectable } from '@angular/core'; import { HttpClient , HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable({ provi
http://localhost:9001
使用angular proxy config,但是我无法调用端点,知道我在下面的代码中实现了什么错误吗
服务台
import { Injectable } from '@angular/core';
import { HttpClient , HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class AdminService {
constructor(private http: HttpClient) {}
private url = "/api/saveClients";
saveClientJobs(data) {
let options = this.createRequestOptions();
console.log("Service", data);
return this.http.post(this.url, data, {
headers: options
});
}
private createRequestOptions() {
let headers = new HttpHeaders({
"Content-Type": "application/json"
});
return headers;
}
}
proxy.config.json
{
"/api/*": {
"target": "http://localhost:9001",
"secure": false,
"logLevel": "debug"
}
}
package.json
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
一切正常,可能是您错误配置了后端路由?是否可以使用
https代理再试一次。