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
|
|
|
|
|
|
|
exports.handler = middleware(handler);
|