JeremySD99 commited on
Commit
9c855bb
·
1 Parent(s): 546f33e

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +2 -2
server.js CHANGED
@@ -1,7 +1,7 @@
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 = getExternalUrl(process.env.SPACE_ID);
@@ -21,7 +21,7 @@ app.get("/", (req, res) => {
21
  function getExternalUrl(spaceId) {
22
  try {
23
  const [username, spacename] = spaceId.split("/");
24
- return `https://chat.openai.com/`;
25
  } catch (e) {
26
  return "";
27
  }
 
1
  const express = require('express');
2
  const proxy = require('express-http-proxy');
3
  const app = express();
4
+ const targetUrl = 'https://chat.openai.com';
5
  const openaiKey = process.env.OPENAI_KEY
6
  const port = 7860;
7
  const baseUrl = getExternalUrl(process.env.SPACE_ID);
 
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
  }