Merge pull request #160 from jhcpeixoto/master

CORS FIX
This commit is contained in:
Flam3rboy 2021-06-25 15:56:26 +02:00 committed by GitHub
commit 4b01d11ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 10650 deletions

10694
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -66,8 +66,8 @@ export class FosscordServer extends Server {
await Config.init(); await Config.init();
this.app.use(GlobalRateLimit); this.app.use(GlobalRateLimit);
this.app.use(Authentication);
this.app.use(CORS); this.app.use(CORS);
this.app.use(Authentication);
this.app.use(BodyParser({ inflate: true, limit: 1024 * 1024 * 2 })); this.app.use(BodyParser({ inflate: true, limit: 1024 * 1024 * 2 }));
const languages = await fs.readdir(path.join(__dirname, "..", "locales")); const languages = await fs.readdir(path.join(__dirname, "..", "locales"));
const namespaces = await fs.readdir(path.join(__dirname, "..", "locales", "en")); const namespaces = await fs.readdir(path.join(__dirname, "..", "locales", "en"));

View File

@ -21,6 +21,7 @@ declare global {
} }
export async function Authentication(req: Request, res: Response, next: NextFunction) { 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")) return next();
if (req.url.startsWith("/api/v8/invites") && req.method === "GET") 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(); if (NO_AUTHORIZATION_ROUTES.some((x) => x.test(req.url))) return next();