I'm using ably and have created a route to generate a token on next.js server using the following code, based on the next example on ably's web site
// src/app/api/getAblyToken/route.ts
import { NextResponse } from "next/server";
import ably from "ably/promises";
export const fetchCache = "force-no-store";
export async function GET() {
const token = await new ably.Rest({
queryTime: true,
key: process.env["ABLY_API_KEY"]!,
}).auth.createTokenRequest({
capability: {
"*": ["subscribe", "publish", "presence"],
},
});
console.log(token);
return NextResponse.json(token);
}
It all works great on my machine but when I deploy to vercel I get error 40104 and 40105.
That basically say that the token was already used or that it's timestamp is invalid.