Error: XMLHttpRequest is not a constructor

I am using cert verifier js in next 13 and using the npm run build command gives me the following error:

TypeError: global$1.XMLHttpRequest is not a constructor

Using the npm run dev command the library works correctly

I am not familiar with next.js so I’m not entirely sure of what you are trying to achieve and in what conjunction this is failing.

Which version of CVJS is being consumed in your project? cjs, esm, node?
In the source file, global$1.XMLHttpRequest should be assigned a value (most likely an XMLHttpRequest constructor), can you check that this happens.

At this point I’m enclined to say this is a problem with next.js.

I’ve seen the bug in one of my project in a node context.

When running in node you need to:

const { Certificate } = require('@blockcerts/cert-verifier-js/dist/verifier-node');