Repository navigation
Replies: 1 comment
|
In Axios v1.x, you can explicitly force the Node.js HTTP adapter directly in your config — no need to import from dist paths: import axios from "axios";
const instance = axios.create({
adapter: "http", // force Node.js HTTP adapter
headers: {
Authorization: `Bearer ${yourToken}`,
},
});Why your workaround does not work in TypeScript:
Root cause of your CORS/Authorization issue: When running inside Check if:
Setting |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Wrote a simple axios script (required import was used) with authorisation header, works fine. When the same script is being used in twilio-node (ts version) and it is complained that Authorization header is not present.
Probably a cors issue. Since twilio-node runs on node, why can't axios use node version of axios instead of browser.
How to specify to use node version of axios in type script? Example in required mode (doesn't work on ts)
require('axios/dist/node/axios.cjs')All reactions