Files
web-check/api/http-security.js
2026-05-05 06:47:13 +01:00

22 lines
712 B
JavaScript

import axios from 'axios';
import middleware from './_common/middleware.js';
import { upstreamError } from './_common/upstream.js';
const httpsSecHandler = async (url) => {
try {
const { headers } = await axios.get(url);
return {
strictTransportPolicy: !!headers['strict-transport-security'],
xFrameOptions: !!headers['x-frame-options'],
xContentTypeOptions: !!headers['x-content-type-options'],
xXSSProtection: !!headers['x-xss-protection'],
contentSecurityPolicy: !!headers['content-security-policy'],
};
} catch (error) {
return upstreamError(error, 'HTTP security check');
}
};
export const handler = middleware(httpsSecHandler);
export default handler;