GithubHelp home page GithubHelp logo

Comments (3)

tanner-reits avatar tanner-reits commented on September 23, 2024

Hey @AliKdhim87!

Thanks for the issue! Do you know if this is a problem without Next.js in the equation? The reproduction feels a bit complicated at the moment, so it would be great if we could strip out some aspects to help isolate the issue!

from stencil.

Yudi avatar Yudi commented on September 23, 2024

Hey, @tanner-reits!

I'm able to reproduce this with Angular on a fresh ionic start project.

I've followed the steps in the documentation, but setNonce() doesn't seem to work.
Angular correctly provides the nonce to CSP_NONCE.


Repo: https://github.com/Yudi/csp-nonce-ionic-error/

To reproduce, I set the following:

	// package.json
    "@ionic/angular": "^8.2.0",
    "@ionic/core": "^8.2.0",
<!-- index.html -->
    <meta
      http-equiv="Content-Security-Policy"
      content="script-src 'self' 'nonce-randomNonceGoesHere'; style-src 'self' 'nonce-randomNonceGoesHere'"
    />
// main.ts

import { setNonce } from '@ionic/core/loader';

...

const nonce = 'randomNonceGoesHere';
setNonce(nonce);

bootstrapApplication(AppComponent, {
  providers: [
    { provide: CSP_NONCE, useValue: nonce },
...

main.ts

image


Console output
image


index.js

image

plt.$nonce$ is undefined
Therefore nonce is undefined



from stencil.

tanner-reits avatar tanner-reits commented on September 23, 2024

@Yudi Changing the import statement in main.ts for the setNonce import to the following resolves the errors:

import { setNonce } from '@ionic/core/components';

I believe what you had originally would work if you were using the Ionic Angular module, but since your app is using the standalone components variation, you need to use this altered import. Hope that works!

from stencil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.