我正在尝试将 Nodejs 后端 api 与 Angular 集成。我在后端应用程序上实施了 passpor-google、passport-github、passport-twitter 策略。
我的后端应用程序网址是http://localhost:3000
我的前端应用程序网址是http://localhost:4200
护照路线
authRouter.get('/github', passport.authenticate('github'));
authRouter.get(
'/github/callback',
passport.authenticate('github', {
failureRedirect: 'http://localhost:4200/login',
}),
authController.sendJWTToken
);
当我从前端应用程序发送请求时,它给我 CORS 错误
AuthService.ts
githubAuth(): Observable<LoginRsp> {
return this.httpClient.get<LoginRsp>(
`${environment.api_url}/auth/github`
);
}
我已经在我的 Nodejs 项目中添加了 CORS。我该如何解决这个问题请帮助我
在 AuthService.ts 中只需使用 window.location.href='{environment.api_url}/auth/github'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)