我正在尝试创建一个将前端和后端资产分开的应用程序.举个例子,假设前端最终将被托管在gh页面上,而后端将被部署在Heroku上.
我想使用OAuth2.0协议来验证我的客户端,GitHub是我的主要提供商.
作为“概念证明”,我想创建一些利用这种身份验证的虚拟应用程序.以下是代码:
前端(Angular2应用程序) – 在localhost:8080上启动
// template
{ {title}}
getServerResponse()
{ {response}}
// component
export class AppComponent {
title = 'app works!';
response = 'server response';
constructor(private http: Http) {}
getServerResponse() {
this.http.get('http://localhost:9000/hello')
.subscribe(res => this.response = JSON.stringify(res.json()));
}
}
后端(Java Spring应用程序) – 在localhost:9000上启动
// Application.java
@SpringBootApplication
@EnableOAuth2Sso
public class Application {
public s