mirror of
https://github.com/Lissy93/web-check.git
synced 2026-05-15 04:00:04 -04:00
22 lines
728 B
JavaScript
22 lines
728 B
JavaScript
import middleware from './_common/middleware.js';
|
|
import { httpGet } from './_common/http.js';
|
|
import { upstreamError } from './_common/upstream.js';
|
|
|
|
const httpsSecHandler = async (url) => {
|
|
try {
|
|
const { headers } = await httpGet(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;
|