@@ -19,10 +19,17 @@ export interface OAuthKeycloakConfig {
19
19
clientSecret ?: string
20
20
/**
21
21
* Keycloak OAuth Server URL
22
- * @example http://192.168.1.10:8080/auth
22
+ * @example http://192.168.1.10:8080
23
23
* @default process.env.NUXT_OAUTH_KEYCLOAK_SERVER_URL
24
24
*/
25
25
serverUrl ?: string
26
+ /**
27
+ * Optional Keycloak OAuth Server URL to use internally, e.g. if Nuxt connects to a Docker hostname while the browser
28
+ * redirect goes to localhost
29
+ * @example http://keycloak:8080
30
+ * @default process.env.NUXT_OAUTH_KEYCLOAK_SERVER_URL_INTERNAL
31
+ */
32
+ serverUrlInternal ?: string
26
33
/**
27
34
* Keycloak OAuth Realm
28
35
* @default process.env.NUXT_OAUTH_KEYCLOAK_REALM
@@ -40,7 +47,7 @@ export interface OAuthKeycloakConfig {
40
47
*/
41
48
authorizationParams ?: Record < string , string >
42
49
/**
43
- * Redirect URL to to allow overriding for situations like prod failing to determine public hostname
50
+ * Redirect URL to allow overriding for situations like prod failing to determine public hostname
44
51
* @default process.env.NUXT_OAUTH_KEYCLOAK_REDIRECT_URL or current URL
45
52
*/
46
53
redirectURL ?: string
@@ -78,9 +85,10 @@ export function defineOAuthKeycloakEventHandler({
78
85
}
79
86
80
87
const realmURL = `${ config . serverUrl } /realms/${ config . realm } `
88
+ const realmURLInternal = `${ config . serverUrlInternal || config . serverUrl } /realms/${ config . realm } `
81
89
82
90
const authorizationURL = `${ realmURL } /protocol/openid-connect/auth`
83
- const tokenURL = `${ realmURL } /protocol/openid-connect/token`
91
+ const tokenURL = `${ realmURLInternal } /protocol/openid-connect/token`
84
92
const redirectURL = config . redirectURL || getOAuthRedirectURL ( event )
85
93
86
94
if ( ! query . code ) {
0 commit comments