ardasen commited on
Commit
cc71b15
·
1 Parent(s): 7e09486

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +8 -4
server.js CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
  const baseUrl = getExternalUrl(process.env.SPACE_ID);
4
  const openaiKey = process.env.OPENAI_KEY;
5
  const proxyKey = process.env.PROXY_KEY; // Your secret proxy key
@@ -29,14 +27,20 @@ app.post("/reverse-proxy-whisper", async (req, res) => {
29
  // Set other fields as needed (e.g., model)
30
  form.append("model", "whisper-1");
31
 
 
 
 
32
  // Forward the form data to the Whisper API
33
  const proxyResponse = await proxy(whisperApiUrl, {
34
  proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
35
- proxyReqOpts.headers["Authorization"] = "Bearer" + openaiKey;
36
  return proxyReqOpts;
37
  },
38
  })(req, res);
39
 
 
 
 
40
  // Pass the Whisper API response back to the client
41
  res.status(proxyResponse.statusCode).send(proxyResponse.body);
42
  } catch (error) {
@@ -60,4 +64,4 @@ app.get('/', (req, res) => {
60
 
61
  app.listen(port, () => {
62
  console.log(`Reverse proxy server running on ${baseUrl}`);
63
- });
 
 
 
1
  const baseUrl = getExternalUrl(process.env.SPACE_ID);
2
  const openaiKey = process.env.OPENAI_KEY;
3
  const proxyKey = process.env.PROXY_KEY; // Your secret proxy key
 
27
  // Set other fields as needed (e.g., model)
28
  form.append("model", "whisper-1");
29
 
30
+ // Log the form data for debugging
31
+ console.log("Form Data:", form);
32
+
33
  // Forward the form data to the Whisper API
34
  const proxyResponse = await proxy(whisperApiUrl, {
35
  proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
36
+ proxyReqOpts.headers["Authorization"] = "Bearer " + openaiKey;
37
  return proxyReqOpts;
38
  },
39
  })(req, res);
40
 
41
+ // Log the proxy response for debugging
42
+ console.log("Proxy Response:", proxyResponse);
43
+
44
  // Pass the Whisper API response back to the client
45
  res.status(proxyResponse.statusCode).send(proxyResponse.body);
46
  } catch (error) {
 
64
 
65
  app.listen(port, () => {
66
  console.log(`Reverse proxy server running on ${baseUrl}`);
67
+ });