1 Star 0 Fork 0

Codream/talk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
start.js 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
vasanth 提交于 2023-06-27 22:01 . Add CORS origin from env variables
const express = require("express");
const path = require("path");
const http = require("http");
const app = express();
const server = http.createServer(app);
const io = require("socket.io")(server, {
cors: { origin: process.env.CORS_ORIGIN ? process.env.CORS_ORIGIN.split(",") : "*" },
});
const signallingServer = require("./server/signalling-server.js");
// Get PORT from env variable else assign 3000 for development
const PORT = process.env.PORT || 3000;
// Server all the static files from www folder
app.use(express.static(path.join(__dirname, "www")));
app.use(express.static(path.join(__dirname, "icons")));
app.use(express.static(path.join(__dirname, "assets")));
app.use(express.static(path.join(__dirname, "node_modules/vue/dist/")));
server.listen(PORT, null, () => {
console.log("Talk server started");
console.log({ port: PORT, node_version: process.versions.node });
});
// serve the landing page
app.get("/", (req, res) => res.sendFile(path.join(__dirname, "www/index.html")));
// serve the terms / legal page
app.get("/legal", (req, res) => res.sendFile(path.join(__dirname, "www/legal.html")));
// All other URL patterns will serve the app.
app.get("/:room", (req, res) => res.sendFile(path.join(__dirname, "www/app.html")));
io.sockets.on("connection", signallingServer);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/codream/talk.git
git@gitee.com:codream/talk.git
codream
talk
talk
master

搜索帮助