Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion demo/vercel/react/use-chat/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion demo/vercel/react/use-client-session/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions docs/get-started/vercel-use-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
Loading