summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 14:54:13 +0100
committerJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 14:54:13 +0100
commitef19ecedb7760617ceb4d215825ab9659c2797ad (patch)
treeafb9eaf6a428df5a663f25ba1a82b11822dc4d66 /src
parentMerge pull request #159 from fosscord/l10n_master (diff)
downloadserver-ef19ecedb7760617ceb4d215825ab9659c2797ad.tar.xz
CORS FIX
Diffstat (limited to 'src')
-rw-r--r--src/Server.ts2
-rw-r--r--src/middlewares/Authentication.ts1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/Server.ts b/src/Server.ts

index 452bc1fe..f979dab2 100644 --- a/src/Server.ts +++ b/src/Server.ts
@@ -66,8 +66,8 @@ export class FosscordServer extends Server { await Config.init(); this.app.use(GlobalRateLimit); - this.app.use(Authentication); this.app.use(CORS); + this.app.use(Authentication); this.app.use(BodyParser({ inflate: true, limit: 1024 * 1024 * 2 })); const languages = await fs.readdir(path.join(__dirname, "..", "locales")); const namespaces = await fs.readdir(path.join(__dirname, "..", "locales", "en")); diff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts
index 4b0f2b38..4b38f1d4 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -21,6 +21,7 @@ declare global { } export async function Authentication(req: Request, res: Response, next: NextFunction) { + if (req.method === "OPTIONS") return res.sendStatus(204); if (!req.url.startsWith("/api")) return next(); if (req.url.startsWith("/api/v8/invites") && req.method === "GET") return next(); if (NO_AUTHORIZATION_ROUTES.some((x) => x.test(req.url))) return next();