Skip to content

Commit

Permalink
feat: allow setting kinde options in nuxt.config
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 24, 2023
1 parent a164e89 commit 4df78da
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ NUXT_KINDE_LOGOUT_REDIRECT_URL="http://localhost:3000"
NUXT_KINDE_POST_LOGIN_REDIRECT_URL="http://localhost:3000/dashboard"
```

You can alternatively set any of these values except the client secret in your `nuxt.config` file:

```ts
export default defineNuxtConfig({
kinde: {
authDomain: 'https://<your_kinde_subdomain>.kinde.com',
clientId: '<your_kinde_client_id>',
redirectURL: 'http://localhost:3000/api/callback',
logoutRedirectURL: 'http://localhost:3000',
postLoginRedirectURL: 'http://localhost:3000/dashboard',
}
})
```

That's it! You can now use Nuxt Kinde in your Nuxt app ✨

## Development
Expand Down
20 changes: 15 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export interface ModuleOptions {
logout?: string
register?: string
}
authDomain?: string
clientId?: string
redirectURL?: string
logoutRedirectURL?: string
postLoginRedirectURL?: string
}

const resolver = createResolver(import.meta.url)
Expand All @@ -30,15 +35,20 @@ export default defineNuxtModule<ModuleOptions>({
// Default configuration options of the Nuxt module
defaults: {
middleware: true,
authDomain: '',
clientId: '',
redirectURL: '',
logoutRedirectURL: '',
postLoginRedirectURL: '',
},
setup(options, nuxt) {
nuxt.options.runtimeConfig.kinde = defu(nuxt.options.runtimeConfig.kinde, {
authDomain: '',
clientId: '',
authDomain: options.authDomain,
clientId: options.clientId,
redirectURL: options.redirectURL,
logoutRedirectURL: options.logoutRedirectURL,
postLoginRedirectURL: options.postLoginRedirectURL,
clientSecret: '',
redirectURL: '',
logoutRedirectURL: '',
postLoginRedirectURL: '',
})

nuxt.options.nitro.virtual ||= {}
Expand Down

0 comments on commit 4df78da

Please sign in to comment.