Spaces:
Running
Running
Download server.js from YUFI-API/ProxyRecGen: direct link, hf CLI and curl.
- Browser
- Download file 563 Bytes
-
https://huggingface.co/spaces/YUFI-API/ProxyRecGen/resolve/abed4cc42e7a56520eabef7d78ffb970ef5afdb9/server.js
- Command line
-
hf download hf://spaces/YUFI-API/ProxyRecGen@abed4cc42e7a56520eabef7d78ffb970ef5afdb9/server.js
-
curl -L -o server.js https://huggingface.co/spaces/YUFI-API/ProxyRecGen/resolve/abed4cc42e7a56520eabef7d78ffb970ef5afdb9/server.js
563 Bytes
| const express = require('express'); | |
| const proxy = require('express-http-proxy'); | |
| const app = express(); | |
| const targetUrl = 'https://api.openai.com'; // OpenAI API endpoint | |
| const openai_key = process.env.OPENAI_KEY | |
| app.use('/', proxy(targetUrl, { | |
| proxyReqOptDecorator: (proxyReqOpts, srcReq) => { | |
| // Modify the request headers if necessary | |
| proxyReqOpts.headers['Authorization'] = 'Bearer '+openai_key; | |
| return proxyReqOpts; | |
| }, | |
| })); | |
| const port = 7860; | |
| app.listen(port, () => { | |
| console.log(`Reverse proxy server listening on port ${port}`); | |
| }); |