@@ -2,7 +2,7 @@ import { type TokenSet } from "@auth/core/types";
2
2
import NextAuth , { type Session as DefaultSession , type User } from "next-auth" ;
3
3
import KeycloakProvider from "next-auth/providers/keycloak" ;
4
4
5
- import { OIDC_CLIENT_ID , OIDC_SERVER_URL , OIDC_SERVER_URL_INTERNAL } from "../config/keycloak" ;
5
+ import { NEXT_PUBLIC_OIDC_CLIENT_ID , NEXT_PUBLIC_OIDC_SERVER_URL , NEXT_PUBLIC_OIDC_SERVER_URL_INTERNAL } from "../config/keycloak" ;
6
6
7
7
export interface Session extends DefaultSession {
8
8
error ?: "RefreshAccessTokenError"
@@ -45,10 +45,10 @@ export const { handlers: { GET, POST }, auth } = NextAuth({
45
45
} else {
46
46
// If the access token has expired, try to refresh it
47
47
try {
48
- const response = await fetch ( `${ OIDC_SERVER_URL_INTERNAL } /protocol/openid-connect/token` , {
48
+ const response = await fetch ( `${ NEXT_PUBLIC_OIDC_SERVER_URL_INTERNAL } /protocol/openid-connect/token` , {
49
49
headers : { "Content-Type" : "application/x-www-form-urlencoded" } ,
50
50
body : new URLSearchParams ( {
51
- client_id : OIDC_CLIENT_ID ,
51
+ client_id : NEXT_PUBLIC_OIDC_CLIENT_ID ,
52
52
grant_type : "refresh_token" ,
53
53
refresh_token : token . refreshToken ,
54
54
} ) ,
@@ -96,8 +96,8 @@ export const { handlers: { GET, POST }, auth } = NextAuth({
96
96
providers : [
97
97
KeycloakProvider ( {
98
98
id : 'keycloak' ,
99
- clientId : OIDC_CLIENT_ID ,
100
- issuer : OIDC_SERVER_URL ,
99
+ clientId : NEXT_PUBLIC_OIDC_CLIENT_ID ,
100
+ issuer : NEXT_PUBLIC_OIDC_SERVER_URL ,
101
101
102
102
// user information will be extracted from the `id_token` claims, instead of making a request to the `userinfo` endpoint
103
103
// https://next-auth.js.org/configuration/providers/oauth
@@ -113,10 +113,10 @@ export const { handlers: { GET, POST }, auth } = NextAuth({
113
113
// would love to use discovery, but can't because since next-auth:v5 token endpoint is called internally
114
114
// also, discovery doesn't seem to work properly: https://github.com/nextauthjs/next-auth/pull/9718
115
115
// wellKnown: `${OIDC_SERVER_URL}/.well-known/openid-configuration`,
116
- token : `${ OIDC_SERVER_URL_INTERNAL } /protocol/openid-connect/token` ,
117
- userinfo : `${ OIDC_SERVER_URL } /protocol/openid-connect/token` ,
116
+ token : `${ NEXT_PUBLIC_OIDC_SERVER_URL_INTERNAL } /protocol/openid-connect/token` ,
117
+ userinfo : `${ NEXT_PUBLIC_OIDC_SERVER_URL } /protocol/openid-connect/token` ,
118
118
authorization : {
119
- url : `${ OIDC_SERVER_URL } /protocol/openid-connect/auth` ,
119
+ url : `${ NEXT_PUBLIC_OIDC_SERVER_URL } /protocol/openid-connect/auth` ,
120
120
// https://authjs.dev/guides/basics/refresh-token-rotation#jwt-strategy
121
121
params : {
122
122
access_type : "offline" ,
0 commit comments