I need to proxy a request from an Angular app to a non-CORS endpoint.
Here’s my request handler in Express:
export const cqlTranslation = (environment: IEnvironment): Router => {
const router = express.Router();
const multerData = multer();
router.post('/', multerData.none(), async (request: Request, response: Response) => {
try {
const data = (await axios.post(environment.translator.api, request.body, {
headers: request.headers,
params: request.params,
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
})).data;
response.send(data);
}
catch (error) {
console.log(error);
response.sendStatus(400);
}
});
return router;
}
What I’m getting back is:
authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID'
I have tried setting NODE_TLS_REJECT_UNAUTHORIZED
:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
but that’s not working. Suggestions in these posts:
How to configure axios to use SSL certificate?
https://github.com/axios/axios/issues/1650
aren’t working either. What are some other options / alternatives I can try?