2023-07-22 16:18:28 +02:00
|
|
|
const axios = require('axios');
|
2023-06-21 15:28:42 +02:00
|
|
|
|
|
|
|
exports.handler = async function(event, context) {
|
|
|
|
const { url } = event.queryStringParameters;
|
|
|
|
|
|
|
|
if (!url) {
|
|
|
|
return {
|
|
|
|
statusCode: 400,
|
2023-07-10 00:23:50 +02:00
|
|
|
body: JSON.stringify({ error: 'url query string parameter is required' }),
|
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
|
|
|
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
2023-07-22 16:18:28 +02:00
|
|
|
body: JSON.stringify(response.headers),
|
2023-06-21 15:28:42 +02:00
|
|
|
};
|
|
|
|
} catch (error) {
|
2023-07-22 16:18:28 +02:00
|
|
|
console.log(error);
|
2023-06-21 15:28:42 +02:00
|
|
|
return {
|
|
|
|
statusCode: 500,
|
2023-07-10 00:23:50 +02:00
|
|
|
body: JSON.stringify({ error: error.message }),
|
2023-06-21 15:28:42 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|