question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency graph doesn't load with CSP that blocks inline scripts

See original GitHub issue

Current Behavior

When generating a static dependency graph with nx dep-graph --file=output/index.html, index.html contains the project data as inline scripts (see this and this). If one wants to deploy this page with a Content Security Policy that prohibits inline scripts, the application fails to load.

Expected Behavior

The application should work when deployed with a Content Security Policy that blocks inline scripts.

Steps to Reproduce

git clone https://github.com/nrwl/nx-examples
cd nx-examples
npm install

npm run dep-graph -- --file=output/index.html

cat << EOF >> serve.json
{
    "public": "output",
    "headers": [{
        "source": "*",
        "headers": [{
            "key": "Content-Security-Policy",
            "value": "script-src 'self'"
        }]
    }]
}

EOF

npx serve@11.3.2

Failure Logs

Content Security Policy: The page's settings blocked the loading of a resource at inline ("script-src").
...
Uncaught TypeError: can't access property "filter", window.affected is undefined

Proposal

Write the project data to a separate script which is loaded from index.html.

Environment

Node : 14.15.4 OS : darwin x64 yarn : 1.22.10

nx : Not Found @nrwl/angular : 11.0.1-rc.0 @nrwl/cli : 11.0.1-rc.0 @nrwl/cypress : 11.0.1-rc.0 @nrwl/devkit : 11.0.1-rc.0 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 11.0.1-rc.0 @nrwl/linter : 11.0.1-rc.0 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : 11.0.1-rc.0 @nrwl/schematics : Not Found @nrwl/tao : 11.0.1-rc.0 @nrwl/web : 11.0.1-rc.0 @nrwl/workspace : 11.0.1-rc.0 typescript : 4.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
philipjfulchercommented, Nov 18, 2021

This issue will be resolved when the merged PR makes it to a release. Look for it soon!

0reactions
SamuelWitkecommented, Aug 19, 2021

Any chance this issue could be opened again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't walk dependency graph - Stack Overflow
Error: Can't walk dependency graph: Cannot find module 'srt' from 'C:\code\html1\main.js'. In my main.js error, I changed:
Read more >
CSP Allow Inline Scripts - Content Security Policy
When you enable CSP, it will block inline scripts, but there are some ways that you can allow inline scripts and still use...
Read more >
Polaris: Faster Page Loads Using Fine ... - The Morning Paper
The dependency graph captures “load-before” relationships between a page's HTML, CSS, JavaScript, and image objects.
Read more >
How to write scripts | Elasticsearch Guide [8.5] | Elastic
Let's start with a complete script and review its constituent parts. First, index a document with a single field so that we have...
Read more >
Polaris: Faster Page Loads Using Fine-grained Dependency ...
The dependency graph captures “load-before” relationships between a page's. HTML, CSS, JavaScript, and image objects. For exam-.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found