Spaces:
Building
Building
Vladimir Alabov
commited on
Commit
•
1ec06bf
1
Parent(s):
372ca45
updated 2
Browse files
server.js
CHANGED
@@ -2,18 +2,20 @@ const express = require('express');
|
|
2 |
const proxy = require('express-http-proxy');
|
3 |
const app = express();
|
4 |
const targetUrl = 'https://api.openai.com';
|
|
|
5 |
const port = 7860;
|
6 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
7 |
|
8 |
app.use('/api', proxy(targetUrl, {
|
9 |
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
10 |
// Modify the request headers if necessary
|
|
|
11 |
return proxyReqOpts;
|
12 |
},
|
13 |
}));
|
14 |
|
15 |
app.get("/", (req, res) => {
|
16 |
-
res.send(`
|
17 |
});
|
18 |
|
19 |
function getExternalUrl(spaceId) {
|
|
|
2 |
const proxy = require('express-http-proxy');
|
3 |
const app = express();
|
4 |
const targetUrl = 'https://api.openai.com';
|
5 |
+
// const openaiKey = process.env.OPENAI_KEY
|
6 |
const port = 7860;
|
7 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
8 |
|
9 |
app.use('/api', proxy(targetUrl, {
|
10 |
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
11 |
// Modify the request headers if necessary
|
12 |
+
// proxyReqOpts.headers['Authorization'] = 'Bearer '+openaiKey;
|
13 |
return proxyReqOpts;
|
14 |
},
|
15 |
}));
|
16 |
|
17 |
app.get("/", (req, res) => {
|
18 |
+
res.send(`This is your ORP URL: ${baseUrl}`);
|
19 |
});
|
20 |
|
21 |
function getExternalUrl(spaceId) {
|