CORS errors embedding Genesys Cloud Messenger in Next.js App Router

We are integrating the Genesys Cloud Web Messaging SDK into a Next.js application using the App Router. The deployment is managed via Terraform, but the runtime integration is failing.

The browser console throws a CORS error when the widget attempts to connect to the Genesys Cloud API endpoints. We have configured the allowed origins in the Genesys Cloud UI, but the issue persists.

Here is the initialization code:

const genApi = new GenesysCloudWebmessagingSdk({
 deploymentId: process.env.NEXT_PUBLIC_DEPLOYMENT_ID,
 locale: 'en-us',
});

The error indicates the preflight request is failing. Is there a specific configuration required for Next.js rewrites?