1

我使用 Auth0 服务,它为我提供了两个 client_id - 用于开发和生产。但是,这必须是内置的源代码:

@Injectable({
  providedIn: 'root'
})
export class AuthService {
  // Create an observable of Auth0 instance of client
  auth0Client$ = (from(
    createAuth0Client({
      domain: 'xxxxx',
      client_id: 'Mx9x.........',
      redirect_uri: `${window.location.origin}/authorize`,
      audience: 'xxxx'
    })
  ) as Observable<Auth0Client>).pipe(
    shareReplay(1), // Every subscription receives the same shared value
    catchError(err => throwError(err))
  );

我很想在本地开发过程中使用一个,另一个用于生产构建。这是可行的吗?谢谢!

4

1 回答 1

2

您可以environment.ts用于开发配置/密钥和 environment.prod.ts生产配置/密钥,在构建期间使用ng build --prod角度environment.ts替换environment-prod.ts

于 2020-03-29T12:40:59.950 回答