diff --git a/README.md b/README.md index 6e56f9305..997973883 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ function Chat({ chatId, clientId }: { chatId: string; clientId?: string }) { The Ably client authenticates via token auth. Create an endpoint that issues token requests: ```typescript -// app/api/auth/ably-token/route.ts +// app/api/auth/token/route.ts import Ably from 'ably'; const ably = new Ably.Rest({ key: process.env.ABLY_API_KEY }); @@ -210,7 +210,7 @@ export async function GET(req: Request) { // Client-side Ably setup const ably = new Ably.Realtime({ authCallback: async (_params, callback) => { - const response = await fetch('/api/auth/ably-token'); + const response = await fetch('/api/auth/token'); const token = await response.json(); callback(null, token); }, diff --git a/demo/vercel/react/use-chat/src/app/api/auth/ably-token/route.ts b/demo/vercel/react/use-chat/src/app/api/auth/token/route.ts similarity index 86% rename from demo/vercel/react/use-chat/src/app/api/auth/ably-token/route.ts rename to demo/vercel/react/use-chat/src/app/api/auth/token/route.ts index 68e49604e..2f6e513cd 100644 --- a/demo/vercel/react/use-chat/src/app/api/auth/ably-token/route.ts +++ b/demo/vercel/react/use-chat/src/app/api/auth/token/route.ts @@ -2,9 +2,9 @@ * Ably JWT token endpoint. * * Issues short-lived JWTs signed with the Ably API key secret. - * The client connects to Ably with `authUrl` pointing here. + * The client connects to Ably with `authCallback` pointing here. * - * See: https://ably.com/docs/ai-transport/sessions-identity/identifying-users-and-agents + * See: https://ably.com/docs/ai-transport/concepts/authentication */ import jwt from 'jsonwebtoken'; diff --git a/demo/vercel/react/use-chat/src/app/providers.tsx b/demo/vercel/react/use-chat/src/app/providers.tsx index 7f562c6d6..635914960 100644 --- a/demo/vercel/react/use-chat/src/app/providers.tsx +++ b/demo/vercel/react/use-chat/src/app/providers.tsx @@ -18,7 +18,7 @@ export function Providers({ clientId, children }: { clientId?: string; children: const ably = new Ably.Realtime({ authCallback: async (_tokenParams, callback) => { try { - const response = await fetch(`/api/auth/ably-token${authParams}`); + const response = await fetch(`/api/auth/token${authParams}`); const jwt = await response.text(); callback(null, jwt); } catch (err) { diff --git a/demo/vercel/react/use-client-session/src/app/api/auth/ably-token/route.ts b/demo/vercel/react/use-client-session/src/app/api/auth/token/route.ts similarity index 86% rename from demo/vercel/react/use-client-session/src/app/api/auth/ably-token/route.ts rename to demo/vercel/react/use-client-session/src/app/api/auth/token/route.ts index 68e49604e..2f6e513cd 100644 --- a/demo/vercel/react/use-client-session/src/app/api/auth/ably-token/route.ts +++ b/demo/vercel/react/use-client-session/src/app/api/auth/token/route.ts @@ -2,9 +2,9 @@ * Ably JWT token endpoint. * * Issues short-lived JWTs signed with the Ably API key secret. - * The client connects to Ably with `authUrl` pointing here. + * The client connects to Ably with `authCallback` pointing here. * - * See: https://ably.com/docs/ai-transport/sessions-identity/identifying-users-and-agents + * See: https://ably.com/docs/ai-transport/concepts/authentication */ import jwt from 'jsonwebtoken'; diff --git a/demo/vercel/react/use-client-session/src/app/providers.tsx b/demo/vercel/react/use-client-session/src/app/providers.tsx index ade4585b4..22f83461d 100644 --- a/demo/vercel/react/use-client-session/src/app/providers.tsx +++ b/demo/vercel/react/use-client-session/src/app/providers.tsx @@ -23,7 +23,7 @@ export function Providers({ clientId, children }: { clientId?: string; children: const ably = new Ably.Realtime({ authCallback: async (_tokenParams, callback) => { try { - const response = await fetch(`/api/auth/ably-token${authParams}`); + const response = await fetch(`/api/auth/token${authParams}`); const jwt = await response.text(); callback(null, jwt); } catch (err) { diff --git a/docs/get-started/vercel-use-chat.md b/docs/get-started/vercel-use-chat.md index cd7963745..a694c1827 100644 --- a/docs/get-started/vercel-use-chat.md +++ b/docs/get-started/vercel-use-chat.md @@ -19,7 +19,7 @@ npm install @ably/ai-transport ably ai @ai-sdk/react @ai-sdk/anthropic react rea The client authenticates with Ably using short-lived JWTs. Create a server endpoint that signs tokens with your Ably API key: ```typescript -// app/api/auth/ably-token/route.ts +// app/api/auth/token/route.ts import jwt from 'jsonwebtoken'; import { NextResponse } from 'next/server'; @@ -64,7 +64,7 @@ export function Providers({ clientId, children }: { clientId?: string; children: const ably = new Ably.Realtime({ authCallback: async (_tokenParams, callback) => { try { - const response = await fetch(`/api/auth/ably-token?clientId=${encodeURIComponent(clientId ?? '')}`); + const response = await fetch(`/api/auth/token?clientId=${encodeURIComponent(clientId ?? '')}`); const jwt = await response.text(); callback(null, jwt); } catch (err) {