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

CSP script-src error #1074

Closed
germsb opened this issue Apr 4, 2018 · 2 comments
Closed

CSP script-src error #1074

germsb opened this issue Apr 4, 2018 · 2 comments

Comments

@germsb
Copy link

germsb commented Apr 4, 2018

Version

3.0.0-beta.6

Steps to reproduce

  1. vue create testapp
  2. Setup as you want.
  3. Add productionSourceMap: false in vue.config.js.
  4. Build and push dist folder to your server.
  5. Add CSP header in your server config.

Content-Security-Policy-report-only "default-src 'none'; script-src 'self'; img-src 'self' data:; style-src 'self' ";

  1. Open the app in browser

What is expected?

according to the Vuejs doc there should be no problem

What is actually happening?

The page return an error

[Report Only] Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-aMW8RJ8d9m3crvBSAvcz8B/pG hlL4Sa2UuvzcOXfAE='), or a nonce ('nonce-...') is required to enable inline execution.


Do you have an idea to get around this?

@yyx990803
Copy link
Member

yyx990803 commented Apr 4, 2018

This is because we are inlining the webpack manifest chunk by default to reduce HTTP requests.

You can use the following to disable the inlining:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.plugins
      .delete('split-manifest')
      .delete('inline-manifest')
  }
}

@darkylmnx
Copy link

@yyx990803 could you add this somewhere in the docs as it was really a pain to find an answer to this issue.

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

3 participants