我正在尝试使用webapi
api:-
@CrossOrigin(origins="http://IP:4200")
@RestController
@RequestMapping("/api/v1")
public class BasicAuthController {
@PostMapping(path = "/authenticate")
public ResponseEntity<?> createAuthenticationToken(@RequestBody JwtRequest authenticationRequest) {
log.info("end createAuthenticationToken method");
return ResponseEntity.ok(userDetailsinfo);
}
}
client:-
authenticationService(formData) {
return this.http.post<any>('/api/v1/authenticate', formData).pipe(map((res) => {
debugger;
}));
}
proxy.config.json文件
{
"/api": {
"target": "http://IP:8080",
"secure": false,
"changeOrigin": true
}
}
我已经使用 ng-serve
2条答案
按热度按时间7rfyedvj1#
您可以在angular.json文件上配置代理配置。请看下面的示例:
或者如前所述,您可以用proxy config proxy.conf.json启动应用程序
jmp7cifd2#
尝试使用此命令启动应用程序以使用代理配置。