Spaces:
Building
Building
Vladimir Alabov
commited on
Commit
•
8db509b
1
Parent(s):
56643f6
'gpr'
Browse files
server.js
CHANGED
@@ -1,32 +1,18 @@
|
|
1 |
const express = require('express');
|
2 |
const proxy = require('express-http-proxy');
|
3 |
const app = express();
|
4 |
-
const targetUrl = 'https://
|
5 |
-
// const openaiKey = process.env.OPENAI_KEY
|
6 |
const port = 7860;
|
7 |
-
const baseUrl = '
|
8 |
|
9 |
-
app.use('/
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
},
|
15 |
}));
|
16 |
|
17 |
app.get("/", (req, res) => {
|
18 |
-
res.send(`This is your
|
19 |
});
|
20 |
-
|
21 |
-
function getExternalUrl(spaceId) {
|
22 |
-
try {
|
23 |
-
const [username, spacename] = spaceId.split("/");
|
24 |
-
return `https://${username}-${spacename.replace(/_/g, "-")}.hf.space/api/v1`;
|
25 |
-
} catch (e) {
|
26 |
-
return "";
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
app.listen(port, () => {
|
31 |
-
console.log(`Reverse proxy server running on ${baseUrl}`);
|
32 |
-
});
|
|
|
1 |
const express = require('express');
|
2 |
const proxy = require('express-http-proxy');
|
3 |
const app = express();
|
4 |
+
const targetUrl = 'https://generativelanguage.googleapis.com';
|
|
|
5 |
const port = 7860;
|
6 |
+
const baseUrl = 'gem';
|
7 |
|
8 |
+
app.use('/', proxy(targetUrl, {
|
9 |
+
https: true,
|
10 |
+
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
|
11 |
+
// console.log(srcReq);
|
12 |
+
return proxyReqOpts;
|
13 |
},
|
14 |
}));
|
15 |
|
16 |
app.get("/", (req, res) => {
|
17 |
+
res.send(`This is your GRP URL: ${baseUrl}`);
|
18 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|