Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Express js : Content security header is not reflecting

In my express js application I have enabled the helmet for the security implementation

const app = express();

app.use(function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});
app.use(helmet(
));

After setting this i m getting CSP error in chrome console

Refused to load the script 'https://code.jquery.com/jquery-3.4.1.min.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

localhost/:1

to resolve this I have added the following meta tag

<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://code.jquery.com/"> 

But still I m getting the error, i tried similar posts in the StackOverflow but nothing resolved my problem

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Figure it out the issue i have to set the CSP through helmet configuration

app.use(helmet.contentSecurityPolicy({
    useDefaults: false,
    directives: {
        defaultSrc: ["'self'"],
        scriptSrc: ["'self'", "'unsafe-inline'","code.jquery.com","*.jsdelivr.net"],
        "style-src":["'self'","'unsafe-inline'","*.cloudflare.com","*.googleapis.com","*.jsdelivr.net"],
        "font-src":["'self'","*.gstatic.com","*.cloudflare.com","*.jsdelivr.net"],
        "img-src":["'self'","data:"]
      }
}));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!