Spaces:
Build error
Build error
File size: 851 Bytes
4af49ed | 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 33 34 | import express from 'express';
import { createServer } from 'node:http';
import { createBareServer } from '@tomphttp/bare-server-node';
import { join } from 'node:path';
const bare = createBareServer('/bare/');
const app = express();
const __dirname = process.cwd();
app.use(express.static(join(__dirname, 'public')));
const server = createServer();
server.on('request', (req, res) => {
if (bare.shouldRoute(req)) {
bare.routeRequest(req, res);
} else {
app(req, res);
}
});
server.on('upgrade', (req, socket, head) => {
if (bare.shouldRoute(req)) {
bare.routeUpgrade(req, socket, head);
} else {
socket.end();
}
});
// Hugging Faceは7860ポート以外受け付けません
const PORT = 7860;
server.listen({ port: PORT }, () => {
console.log(`Proxy is running on port ${PORT}`);
}); |