2023-07-22 16:18:28 +02:00
|
|
|
const axios = require('axios');
|
2023-08-09 23:33:36 +02:00
|
|
|
const middleware = require('./_common/middleware');
|
2023-06-21 15:28:42 +02:00
|
|
|
|
2023-08-09 23:33:36 +02:00
|
|
|
const handler = async (url, event, context) => {
|
2023-06-21 15:28:42 +02:00
|
|
|
try {
|
2023-07-22 16:18:28 +02:00
|
|
|
const response = await axios.get(url, {
|
|
|
|
validateStatus: function (status) {
|
|
|
|
return status >= 200 && status < 600; // Resolve only if the status code is less than 600
|
|
|
|
},
|
|
|
|
});
|
2023-06-21 15:28:42 +02:00
|
|
|
|
2023-08-09 23:33:36 +02:00
|
|
|
return response.headers;
|
2023-06-21 15:28:42 +02:00
|
|
|
} catch (error) {
|
2023-08-09 23:33:36 +02:00
|
|
|
throw new Error(error.message);
|
2023-06-21 15:28:42 +02:00
|
|
|
}
|
|
|
|
};
|
2023-08-09 23:33:36 +02:00
|
|
|
|
2023-09-03 13:27:04 +02:00
|
|
|
module.exports = middleware(handler);
|
|
|
|
module.exports.handler = middleware(handler);
|