From 4c748013fa0f94979488a9c80b3ad2ead2865569 Mon Sep 17 00:00:00 2001
From: Wassim Bougarfa <12980387+wassimoo@users.noreply.github.com>
Date: Tue, 18 Nov 2025 15:59:19 +0100
Subject: [PATCH 1/2] feat: Update dependencies and fix environment variables
references
---
README.md | 7 +-
app/middleware-example/page.tsx | 6 +-
auth.ts | 37 +-
components/auth-components.tsx | 2 +-
components/main-nav.tsx | 4 +-
next-env.d.ts | 1 +
package-lock.json | 1561 +++++++++++++++++++++----------
package.json | 36 +-
middleware.ts => proxy.ts | 6 +-
tsconfig.json | 23 +-
10 files changed, 1118 insertions(+), 565 deletions(-)
rename middleware.ts => proxy.ts (80%)
diff --git a/README.md b/README.md
index 7dbf2d85..4cded8df 100644
--- a/README.md
+++ b/README.md
@@ -23,10 +23,11 @@ The integration uses Ory as an OIDC provider with Auth.js, passing essential ide
To run this example, you'll need to configure the following environment variables:
```
-ORY_SDK_URL=https://your-ory-project.projects.oryapis.com
-ORY_CLIENT_ID=your-client-id
-ORY_CLIENT_SECRET=your-client-secret
+AUTH_ORY_SDK_URL=https://your-ory-project.projects.oryapis.com
+AUTH_ORY_CLIENT_ID=your-client-id
+AUTH_ORY_CLIENT_SECRET=your-client-secret
+AUTH_SECRET=your-auth-secret
AUTH_KV_REST_API_URL=your-vercel-kv-url (optional)
AUTH_KV_REST_API_TOKEN=your-vercel-kv-token (optional)
AUTH_DEBUG=true (optional)
diff --git a/app/middleware-example/page.tsx b/app/middleware-example/page.tsx
index 370e0cf7..a60955ce 100644
--- a/app/middleware-example/page.tsx
+++ b/app/middleware-example/page.tsx
@@ -3,15 +3,15 @@ import CustomLink from "@/components/custom-link"
export default function Page() {
return (
-
Middleware usage
+
Proxy usage
This page is protected by using the universal{" "}
auth()
{" "}
method in{" "}
-
- Next.js Middleware
+
+ Next.js Proxy
.
diff --git a/auth.ts b/auth.ts
index c1f4257d..82bdc4d8 100644
--- a/auth.ts
+++ b/auth.ts
@@ -17,26 +17,33 @@ const storage = createStorage({
})
export const { handlers, auth, signIn, signOut } = NextAuth({
+ secret: process.env.AUTH_SECRET,
debug: !!process.env.AUTH_DEBUG,
theme: { logo: "https://authjs.dev/img/logo-sm.png" },
adapter: UnstorageAdapter(storage),
providers: [
// highlight-start
- {
- id: "ory",
- name: "Ory",
- type: "oidc",
- style: {
- logo: "/ory.svg",
- },
- issuer: process.env.ORY_SDK_URL,
- clientId: process.env.ORY_CLIENT_ID,
- clientSecret: process.env.ORY_CLIENT_SECRET,
- checks: ["pkce" as never, "state" as never],
- token: {
- idToken: true,
- },
- },
+ ...(process.env.AUTH_ORY_SDK_URL &&
+ process.env.AUTH_ORY_CLIENT_ID &&
+ process.env.AUTH_ORY_CLIENT_SECRET
+ ? [
+ {
+ id: "ory",
+ name: "Ory",
+ type: "oidc" as const,
+ style: {
+ logo: "/ory.svg",
+ },
+ issuer: process.env.AUTH_ORY_SDK_URL,
+ clientId: process.env.AUTH_ORY_CLIENT_ID,
+ clientSecret: process.env.AUTH_ORY_CLIENT_SECRET,
+ checks: ["pkce" as never, "state" as never],
+ token: {
+ idToken: true,
+ },
+ },
+ ]
+ : []),
// highlight-eng
],
basePath: "/auth",
diff --git a/components/auth-components.tsx b/components/auth-components.tsx
index b004538a..a264924a 100644
--- a/components/auth-components.tsx
+++ b/components/auth-components.tsx
@@ -26,7 +26,7 @@ export async function SignOut(
// This redirect has to be in the list of allowed post_logout_redirect_uris in the OAuth2 Client.
const redirectTo = "http://localhost:3000/"
const oidcLogout =
- process.env.ORY_SDK_URL +
+ process.env.AUTH_ORY_SDK_URL +
`/oauth2/sessions/logout?id_token_hint=${session?.idToken}&post_logout_redirect_uri=${redirectTo}`
return (