GrowGen | 整

cloudflare worker 增加 CSP

J.Gong

2019-09-10

0.17min

cloudflare worker 增加 CSP

addEventListener('fetch', event => {

  event.respondWith(fetch(event.request)
      .then(function(response){
            response = new Response(response.body, response);
            // Set content-security-policy header to self and also include 
            // cloudflare workers dashboard to make it easy to preview
            response.headers.set("content-security-policy",
               "frame-ancestors 'self' https://dash.cloudflare.com;");

            return response;
        }

      ));
    

});

J.Gong

相关文章

Tags

fe

© 2025 我的技术博客. 保留所有权利.

使用 Astro.build + Mantine 构建 | 部署在 Vercel