diff --git a/lib/core/middleware/nuxt.js b/lib/core/middleware/nuxt.js index 97a1981a7b..6f4fde6cbe 100644 --- a/lib/core/middleware/nuxt.js +++ b/lib/core/middleware/nuxt.js @@ -71,10 +71,10 @@ export default async function nuxtMiddleware(req, res, next) { if (this.options.render.csp && this.options.render.csp.enabled) { const allowedSources = this.options.render.csp.allowedSources const policies = this.options.render.csp.policies - let cspStr = `script-src 'self' ${(cspScriptSrcHashes).join(' ')}` + let cspStr = `script-src 'self'${this.options.dev ? " 'unsafe-eval'" : ''} ${(cspScriptSrcHashes).join(' ')}` if (Array.isArray(allowedSources)) { // For compatible section - cspStr = `script-src 'self' ${cspScriptSrcHashes.concat(allowedSources).join(' ')}` + cspStr += ' ' + allowedSources.join(' ') } else if (typeof policies === 'object' && policies !== null && !Array.isArray(policies)) { // Set default policy if necessary if (!policies['script-src'] || !Array.isArray(policies['script-src'])) {