Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I add a security header? #139

Closed
zufan-students opened this issue Jun 9, 2024 · 0 comments
Closed

how do I add a security header? #139

zufan-students opened this issue Jun 9, 2024 · 0 comments

Comments

@zufan-students
Copy link

Problem:

I have tried adding a security header to config/development/server.toml and hugo.toml with no effect after adding the security header script with:

hugo.toml

[server]
  [[server.headers]]
    for = '/**'
    [server.headers.values]
      Content-Security-Policy = 'script-src localhost:1313'
      Referrer-Policy = 'strict-origin-when-cross-origin'
      X-Content-Type-Options = 'nosniff'
      X-Frame-Options = 'DENY'
      X-XSS-Protection = '1; mode=block'

config/development/server.toml

[[headers]]
  for = '/**'
  [headers.values]
    Content-Security-Policy = 'script-src localhost:1313'
    Referrer-Policy = 'strict-origin-when-cross-origin'
    X-Content-Type-Options = 'nosniff'
    X-Frame-Options = 'DENY'
    X-XSS-Protection = '1; mode=block'

request

how to add security headers i run on vercel with this Hugoplate theme? by adding to vercel.json? I've tried adding it but this script gets an error it's not allowed to use routes it has to be rewritten. Can you make an example?

 "routes": [
 {
 "handle": "filesystem"
 },
 {
 "src": "/(.*)",
 "status": 404,
 "dest": "/404.html"
 }

example vercel.json

before:

{
 "builds": [
   {
     "src": "vercel-build.sh",
     "use": "@vercel/static-build",
     "config": {
       "distDir": "public"
     }
   }
 ],
 "routes": [
   {
     "handle": "filesystem"
   },
   {
     "src": "/(.*)",
     "status": 404,
     "dest": "/404.html"
   }
 ]
}

after:

 request sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant