Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -7,14 +7,12 @@ const proxyKey = process.env.PROXY_KEY; // Your secret proxy key
|
|
| 7 |
const port = 7860;
|
| 8 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
| 9 |
|
| 10 |
-
const openaiKey = process.env.OPENAI_KEY; // Load the OpenAI API key from your environment variables
|
| 11 |
-
const validProxyKey = 'your-valid-proxy-key'; // Replace with your valid proxy key
|
| 12 |
|
| 13 |
app.get('/getOpenAIKey', (req, res) => {
|
| 14 |
const providedProxyKey = req.headers['x-proxy-key']; // Assuming the proxy key is sent in the 'x-proxy-key' header
|
| 15 |
|
| 16 |
// Check if both OpenAI API key and valid proxy key are provided and match
|
| 17 |
-
if (providedProxyKey ===
|
| 18 |
// Return the OpenAI API key as a JSON response
|
| 19 |
res.json({ apiKey: openaiKey });
|
| 20 |
} else {
|
|
|
|
| 7 |
const port = 7860;
|
| 8 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
app.get('/getOpenAIKey', (req, res) => {
|
| 12 |
const providedProxyKey = req.headers['x-proxy-key']; // Assuming the proxy key is sent in the 'x-proxy-key' header
|
| 13 |
|
| 14 |
// Check if both OpenAI API key and valid proxy key are provided and match
|
| 15 |
+
if (providedProxyKey === proxyKey) {
|
| 16 |
// Return the OpenAI API key as a JSON response
|
| 17 |
res.json({ apiKey: openaiKey });
|
| 18 |
} else {
|