-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcors-proxy.js
More file actions
32 lines (27 loc) · 735 Bytes
/
Copy pathcors-proxy.js
File metadata and controls
32 lines (27 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import cors from 'cors';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
const app = express();
app.use(cors());
app.use(
createProxyMiddleware('/api', {
target: 'https://labs.openai.com/api/labs',
pathRewrite: { '^/api': '' },
changeOrigin: true,
logLevel: 'debug',
logProvider: () => console,
}),
);
app.use(
createProxyMiddleware('/images', {
target: 'https://openailabsprodscus.blob.core.windows.net',
pathRewrite: { '^/images': '' },
changeOrigin: true,
logLevel: 'debug',
logProvider: () => console,
}),
);
const port = process.env.PORT || 5174;
app.listen(port, () => {
console.log(`CORS proxy listening on port ${port}`);
});