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.

Unable to use styled-components

See original GitHub issue
styled-components.browser.esm.js:133 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='), or a nonce ('nonce-...') is required to enable inline execution.

It is unable to add style now.

I tried to add

  session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
    callback({
      responseHeaders: {
        'Content-Security-Policy': ["default-src 'self' 'unsafe-inline' 'unsafe-eval'"],
        ...details.responseHeaders,
      },
    });
  });

But still can’t get around this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
reZachcommented, Jan 28, 2020

This is a new library for me, thank you for sharing. I take it with your earlier modification adding 'unsafe-inline' is the way to go to use styled-components. Thank you for sharing your solution with us here.

0reactions
Slapboxcommented, Feb 5, 2021

Relevant to #53

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending styles with styled-components not working
I'm trying to extend styles for a react component using styled-components but is not working. AFAIK, I'm doing it the right way, ...
Read more >
FAQs - styled-components
In a React Native project using TypeScript, it is because you need to add @types/styled-components-react-native.
Read more >
Module not found: Can't resolve 'styled-components'
To solve the error "Module not found: Error: Can't resolve 'styled-components'", make sure to install the styled-components package by opening your terminal ...
Read more >
styled-components - npm
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress. Latest version: 5.3.6, ......
Read more >
Unable to install styled-components module : r/reactnative
Hi All, I am trying to install styled components to my expo managed react native ... use npm install --force or better yet,...
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