docgen
docgen copied to clipboard
Refused to execute inline script because it violates the following Content Security Policy directive
Exported my Node API calls from Postman then used Docgen to generate my index.html file then copied to the root of my public folder. When I view the html file via my node server in the browser I am getting a console errors. The first error complained about the favicon.ico so I copied one to the public folder which removed the error. I am unable to remove the CSP error after trying suggested methods in the error using Helmet middleware options.
If open html file directly with the browser I don't get the CSP error so it only happens when I accessing the file via Node API server root. Please advice, full error listed below.
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-ZomnyosL2bmZ79LmErHEhL+1fVaBj9NngvpOK/l4qio='), or a nonce ('nonce-...') is required to enable inline execution.
For me is the same
Facing exactly same issue, this need to be solved
I moved inline script to new js file and it worked for me.
I moved inline script to new js file and it worked for me.
but how ?
- Open index.html file
- Grab all functionality from
- Create new file FE: js.js near the index.html
- Paste functionality from script tag into new js.js file
- Connect js file into index.html file ->
This also worked for me (i.e. the comments from @VighneshManjrekar )