Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
What is wrong in my implementation of nonce for a inline-js with csp and flask?

I have implemented a nonce for a csp inline js. Struggling with finding why it doesn't work. When accessing a page get this error:

Content Security Policy: The page's settings blocked the loading of a resource at https://loca.../script.js ("script-src").
Content Security Policy: The page's settings blocked the loading of a resource at inline ("script-src").

Implempleted to flask: // Inside timer.py file implemented a function to create nonce.

def GetCspNonce():
  """Returns a random nonce."""
  NONCE_LENGTH = 16
  return base64.b64encode(os.urandom(NONCE_LENGTH))

nonce = GetCspNonce()

function to redirect to a template:
return render_template('base/timer.html', timer= timer, nonce=nonce)

// Added to init.py csp nonce.

def create_app():
    # create and configure the app
....

    csp = {
        'default-src': ['\'self\''],
        'script-src': ['https://www.goog....], 'nonce-{nonce}'],...

//timer.html

<td> 
    <p> ...</p>

        <script type="text/javascript" src="../static/text/script.js" nonce="{nonce}"></script>

            </td>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda