- Get link
- X
- Other Apps
| Section 1: English Version | Bagian 2: Versi Bahasa Indonesia |
|---|---|
🔐 Critical Lineconst openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
This is the most important security component in your integration.
|
🔐 Baris Krusialconst openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
Ini adalah bagian keamanan paling penting dalam integrasi Anda.
|
|
Breakdown: 1. new OpenAI(): Connects server to API.2. apiKey: Your authentication credential (Password).3. process.env: Retrieves key from a protected server variable.
|
Penjelasan: 1. new OpenAI(): Menghubungkan server ke API.2. apiKey: Kredensial autentikasi Anda (Password).3. process.env: Mengambil key dari variabel server yang terlindungi.
|
|
❌ DANGEROUS Never hardcode the key directly like apiKey: "sk-xxx". It will be visible in source code and can be stolen by bots.
|
❌ BERBAHAYA Jangan tulis key langsung seperti apiKey: "sk-xxx". Key akan terlihat di kode dan bisa dicuri oleh bot otomatis.
|
|
🛡 BEST PRACTICE Always use Environment Variables (.env). Ensure this file is added to .gitignore.
|
🛡 PRAKTIK TERBAIK Selalu gunakan Environment Variables (.env). Pastikan file ini dimasukkan ke dalam .gitignore.
|
← Scroll horizontally to compare content →
Summary | Ringkasan
EN: The API key must remain on the backend only. Never inside HTML or frontend JS.
ID: API key harus berada di backend saja. Jangan pernah ditaruh di HTML atau JS frontend.
Warning | Peringatan
Hardcoding "sk-xxxx" allows hackers to steal your balance.
Hardcoding key membuat saldo Anda bisa dicuri hacker.
Comments