Vladimir Alabov commited on
Commit
8db509b
1 Parent(s): 56643f6
Files changed (1) hide show
  1. server.js +8 -22
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://api.openai.com';
5
- // const openaiKey = process.env.OPENAI_KEY
6
  const port = 7860;
7
- const baseUrl = 'kek'// 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) {
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
  });