Skip to content

Instantly share code, notes, and snippets.

@argentinaluiz
Created December 27, 2018 15:39
Show Gist options
  • Select an option

  • Save argentinaluiz/1329ded1008ec5c0623c2586eb038fe2 to your computer and use it in GitHub Desktop.

Select an option

Save argentinaluiz/1329ded1008ec5c0623c2586eb038fe2 to your computer and use it in GitHub Desktop.
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {JwtModule, JWT_OPTIONS} from '@auth0/angular-jwt';
export function jwtFactory(authService) {
return {
whitelistedDomains: [
new RegExp('localhost:8000/*'),
],
tokenGetter: () => {
return authService.getToken()
}
}
}
@NgModule({
declarations: [
],
imports: [
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtFactory,
deps: [AuthService]
}
})
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment