Advertisement
fakesamgregory

Cloudfront Functions — Content Security Policy

Aug 27th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.67 KB | Source Code | 0 0
  1. async function handler(event) {
  2.     const response = event.response;
  3.     const headers = response.headers;
  4.  
  5.     // Set HTTP security headers according to your errors (try wildcards * because YOLO)
  6.     headers['content-security-policy'] = { value: "default-src 'none'; img-src 'self' data: https:; script-src 'self'; style-src 'unsafe-inline'; object-src 'none'; frame-ancestors 'none'; script-src-elem 'self' 'unsafe-inline' https://www.googletagmanager.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; font-src 'self'; style-src-elem 'self' 'unsafe-inline' https://xnewworlds.jatg.co; media-src *"}
  7.    
  8.     // Return the response to viewers
  9.     return response;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement