【发布时间】:2020-05-26 21:50:47
【问题描述】:
我正在写一个如下的休息电话
authenticationService(username: string, password: string) {
debugger;
let params = new HttpParams();
params = params.append('username', username);
params = params.append('password', password);
return this.http.get(`http://localhost:8080/api/v1/basicauth?`,{params},
).pipe(map((res) => {
this.username = username;
this.password = password;
}));
}
从春季启动结束,我正在使用@RequestParams,如下所示
@GetMapping(path = "/basicauth")
public AuthenticationBean helloWorldBean(@RequestParam(name = "username") String username,@RequestParam(name = "password") String password) {
String status = authenticationService.isUserAuthenticated(username, password);
return new AuthenticationBean("You are not authenticated");
}
我收到类似
的错误请帮我解决这个问题。谢谢:)
【问题讨论】:
-
我不认为这个问题与 CORS 有关。
-
@Codelover,尝试将@CrossOrigin(origins = "host://url_of_your_frontend_server:port") 添加到您的控制器。
-
@NikitaLebed @CrossOrigin(origins="localhost:4200") 我已经添加了。
-
@Codelover 也发布您的跨源配置文件,并从您的 cmets 发布您缺少的协议 (http)
标签: java angular spring typescript spring-boot