From e971ba1b62ce486275de85d5f8762561b28f261b Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 19 Apr 2021 22:00:48 +0200 Subject: [PATCH] :art: change default port to 1000 + CORS --- src/index.ts | 2 +- src/middlewares/CORS.ts | 7 +++++++ src/routes/gateway.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/middlewares/CORS.ts diff --git a/src/index.ts b/src/index.ts index 3a05cdfa..6a0fabc4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ config(); import { DiscordServer } from "./Server"; var port = Number(process.env.PORT); -if (isNaN(port)) port = 3000; +if (isNaN(port)) port = 1000; const server = new DiscordServer({ port }); server.start().catch(console.error); diff --git a/src/middlewares/CORS.ts b/src/middlewares/CORS.ts new file mode 100644 index 00000000..336051bd --- /dev/null +++ b/src/middlewares/CORS.ts @@ -0,0 +1,7 @@ +import { NextFunction, Request, Response } from "express"; + +// TODO: config settings + +export function CORS(req: Request, res: Response, next: NextFunction) { + res.set("Access-Control-Allow-Origin", "*"); +} diff --git a/src/routes/gateway.ts b/src/routes/gateway.ts index 53302f12..edbb8890 100644 --- a/src/routes/gateway.ts +++ b/src/routes/gateway.ts @@ -3,7 +3,7 @@ import { Router } from "express"; const router = Router(); router.get("/", (req, res) => { - res.send({ url: "ws://localhost:8080" }); + res.send({ url: "ws://localhost:2000" }); }); export default router;