The docs state: “Ensure the Origin header matches a registered domain in the Genesys Cloud web messaging configuration.”
I’m embedding the Genesys Cloud Messenger widget into a Next.js app (App Router). The widget loads, but the initial handshake to fetch the config fails with a CORS error. The browser console shows:
Access to fetch at 'https://api.mypurecloud.com/api/v2/messenger/config' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I’ve added http://localhost:3000 to the Allowed Origins list in the Genesys Cloud UI under Web Messaging > Configuration. The list looks like this in the JSON response from the config endpoint:
{
"allowedOrigins": [
"https://prod.example.com",
"http://localhost:3000"
]
}
The Next.js server is making the request server-side during SSR (or ISR), which might be stripping headers or sending a different User-Agent, but the Origin header in the network tab definitely says http://localhost:3000.
I’m using the standard @genesyscloud/messenger package. The init call is straightforward:
import { Messenger } from '@genesyscloud/messenger';
const messenger = new Messenger({
orgGuid: 'my-org-guid',
deploymentId: 'my-deployment-id',
origin: 'http://localhost:3000'
});
await messenger.init();
The init() method hangs and eventually throws the network error. If I disable SSR and run it purely client-side on a static page, it works. But we need this to hydrate properly.
Is there a specific header the Next.js server needs to pass along with the Origin, or is the Genesys Cloud API rejecting preflights from localhost even when explicitly allowed? I’ve tried adding Access-Control-Request-Headers manually via a custom fetch wrapper, but that just returns a 403. The docs don’t mention any special handling for Next.js server components.