Add Security Headers via Workers


first of all - I am an integrator, not a developer, so quite a beginner in using Workers!

I want to add http security headers to my webpage and found the following Workers code:

I added a new Worker with that code (unchanged, except value of “X-Frame-Options” set to SAMEORIGIN.

I also added a route with the pattern and chose the newly created Worker as the service and “production” as environment.
I also purged the cache, but when inspecting the headers, they don’t appear.

Any idea, how I get this working / debugged?

Thanks in advance for any help!

Cheers Peter

Got it solved by changing the URL parameter to


I’m glad to hear you’ve jumped into the world of Workers.

With the new Transform Rules for response headers, you no longer need to do this with Workers.

Thanks - good to know, makes it much easier to maintain!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.