Angular与OKTA集成在将Angular代码部署到Web服务器时不起作用。
创始人
2024-10-30 18:30:31
0

可能是由于CORS策略引起的。在Web服务器上添加CORS策略以允许来自OKTA的请求,并确保在将Angular代码部署到Web服务器之前,将OKTA配置正确注入到应用程序中。

示例代码:

  1. 在Web服务器上添加CORS策略(此示例使用Node.js):

const express = require('express'); const cors = require('cors'); const app = express(); app.use(cors());

  1. 在Angular中,确保正确注入OKTA配置:

import { OktaAuthService } from '@okta/okta-angular';

export class AppComponent { isAuthenticated: boolean;

constructor(public oktaAuth: OktaAuthService) { this.oktaAuth.isAuthenticated().subscribe(isAuthenticated => { this.isAuthenticated = isAuthenticated; }); } }

注意:确保将OKTA配置添加到app.module.ts文件中:

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { HttpClientModule } from '@angular/common/http'; import { AppComponent } from './app.component'; import { OktaAuthModule } from '@okta/okta-angular';

@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, HttpClientModule, OktaAuthModule.initAuth({ issuer: 'https://{yourOktaDomain}.com/oauth2/default', clientId: '{clientId}', redirectUri: 'http://localhost:4200/implicit/callback', pkce: true }) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }

这些步骤应该解决问题并确保Angular与OKTA集成在将Angular代码部署到Web服务器时能够正常工作。

相关内容

热门资讯

aapoker有外挂!wpk有... aapoker有外挂新手教程相关信息汇总(需添加指定Q群1067239143获取下载链接);aapo...
wepower有外挂!wpk号... wepower有外挂!wpk号一直输,德扑之星创建房间设置,科技教程(有挂介绍)1.wepower有...
wepokeai代打!微扑克w... wepokeai代打!微扑克wpk真的有辅助吗,(aApoker)原本有挂(详细辅助必胜教程)准备好...
德州ai辅助软件!aapoke... 德州ai辅助软件!aapoker安卓版辅助,(aapoKer)一直真的是有挂(详细辅助AI教程);1...
wepower有外挂!wepo... WePoke高级策略深度解析‌;wepower有外挂!wepoke软件透明挂检测,(wePOKE)固...
德州ai辅助软件!菠萝德州ap... 德州ai辅助软件!菠萝德州app挂哪里买,(wepoKE)本然真的有挂(详细辅助必胜教程)是一款可以...
wepoke的确有挂!aa p... wepoke的确有挂!aa poker有没有挂,(wePOKE)从来是真的有挂(详细透视存在挂教程)...
微扑克有辅助挂!pokerx机... 微扑克有辅助挂!pokerx机器人,德州aapoker俱乐部外挂,黑科技教程(有挂介绍)1、超多福利...
aapoker有外挂!gg扑克... aapoker有外挂!gg扑克发牌系统,(德扑之星)竟然有挂(详细辅助线上教程)是由北京得aapok...
德州之星有辅助挂!德州ai辅助... 德州之星有辅助挂!德州ai辅助神器燃油,(aaPoker)总是真的有挂(详细辅助大神讲解);玩家必备...