Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

311
Visualizações
How can I run Javascript on Django without exposing static files?

On my Django site, I used Stripe to integrate payments in a .js file.

I noticed that this file appears under Sources in the developer tools when you "Inspect Element" on any browser. Anyone can access this file (scary).

How can I restructure my file organization so that apple-pay.js is not public facing?

home.html

{% load static %}
<!DOCTYPE html>
<html>
<head>
    // Scripts for CSS and Stripe Pay
</head>
<body>
    <section>
        
       <div id="payment-request-button" data-amount="{{event.price}}" data-label=". 
          {{event.public_name}}">
                    <!-- A Stripe Element will be inserted here if the browser supports this type of payment method. -->
       </div>
       <div id="messages" role="alert"></div>

    </section>

</body>
</html>

apple-pay.js

document.addEventListener('DOMContentLoaded', async () => { 
    const stripe = Stripe('pk_mykeyishere'); //need to protect this information and the other functions from bad actors

    ///functions I run here
    
});

My file structure:

├── Procfile
├── README.md
├── db.sqlite3
├── interface
│   ├── migrations
│   ├── models.py
│   ├── static
│   │   ├── apple-developer-merchantid-domain-association
│   │   └── interface
│   │       ├── apple-pay.js <------------------
│   │       ├── CSS/other JS files
│   ├── templates
│   │   └── interface
│   │       ├── home.html <-------------------
│   ├── urls.py
│   └── views.py
├── manage.py
└── AppName
    ├── settings.py
    ├── urls.py
    └── wsgi.py
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You cannot hide JavaScript code from browser users, you can only minify and/or obscure it to make it harder for people to read and understand.

Stripe integration does not require you to put sensitive data into any JavaScript file. You should use that data on the server-side.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda