mirror of
https://github.com/Lissy93/web-check.git
synced 2025-08-09 05:04:31 +02:00
Writes server functions to get cookied and headers
This commit is contained in:
27
server/lambda/get-cookies.js
Normal file
27
server/lambda/get-cookies.js
Normal file
@ -0,0 +1,27 @@
|
||||
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 cookies = response.headers.get('set-cookie');
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({ cookies }),
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
statusCode: 500,
|
||||
body: JSON.stringify({ message: error.message }),
|
||||
};
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user