Reputation: 5210
I'm following the NodeJS Twilio SDK docs with the following:
const twilio = require('twilio')
exports.sendActivationCode = async (phone, activationCode) => {
const accountSID = '<REDACTED>'
const authToken = '<REDACTED>'
const client = twilio(accountSID, authToken)
return await client.messages.create({
body: `Your activation code is ${activationCode}`,
from: '+1<REDACTED>',
to: `+1${phone.toString().replace(/\D/g, '')}`
})
}
I've checked this numerous times to ensure I have a direct match with the docs. When I try to run the code I get Error: Headers User-Agent forbidden
. The request itself shows the header is going out: 'User-Agent': 'twilio-node/3.45.0 (node.js v10.15.3)'
and the stack output indicates that this is coming from jsdom
-> xhr-utils
.
Upvotes: 2
Views: 795
Reputation: 11
This is what fixed it for me. Just add the following to your package.json
file.
"jest": {
"testEnvironment": "node"
},
Found here: https://medium.com/@kevinsimper/how-to-disable-jsdom-in-jest-make-jest-run-twice-as-fast-a01193f23405
Upvotes: 1