mirror of
https://github.com/Lissy93/web-check.git
synced 2024-11-30 04:05:29 +01:00
28 lines
580 B
JavaScript
28 lines
580 B
JavaScript
|
const fetch = require('node-fetch');
|
||
|
|
||
|
exports.handler = async function(event, context) {
|
||
|
const { url } = event.queryStringParameters;
|
||
|
|
||
|
if (!url) {
|
||
|
return {
|
||
|
statusCode: 400,
|
||
|
body: JSON.stringify({ message: 'url query string parameter is required' }),
|
||
|
};
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
const response = await fetch(url);
|
||
|
const headers = response.headers.raw();
|
||
|
|
||
|
return {
|
||
|
statusCode: 200,
|
||
|
body: JSON.stringify(headers),
|
||
|
};
|
||
|
} catch (error) {
|
||
|
return {
|
||
|
statusCode: 500,
|
||
|
body: JSON.stringify({ message: error.message }),
|
||
|
};
|
||
|
}
|
||
|
};
|