2023-06-21 15:28:42 +02:00
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
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 {
|
|
|
|
const response = await fetch(url);
|
|
|
|
const headers = response.headers.raw();
|
|
|
|
|
|
|
|
return {
|
|
|
|
statusCode: 200,
|
|
|
|
body: JSON.stringify(headers),
|
|
|
|
};
|
|
|
|
} catch (error) {
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|