CORS error embedding Genesys Messenger in Next.js

Trying to add the messenger widget to a Next.js app. Getting a CORS error on the init call. Here is the setup:

const script = document.createElement('script');
script.src = 'https://messenger-widget.prod.genesyscloud.com/messenger.js';
script.async = true;

The widget loads but the API calls fail with 403. Any ideas?