From 9bb4d00a0af66a69ec232dd68846710ec4ce3f87 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Thu, 25 May 2023 14:07:48 +0500 Subject: [PATCH] fix cors --- dashboard/app.js | 2 ++ dashboard/routes/docs.js | 2 -- package-lock.json | 13 +++++++++++++ package.json | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dashboard/app.js b/dashboard/app.js index ede14cff..ac25768d 100644 --- a/dashboard/app.js +++ b/dashboard/app.js @@ -6,6 +6,7 @@ module.exports.init = async(client) => { /* Init express app */ const express = require("express"), session = require("express-session"), + cors = require("cors"), path = require("path"), app = express(); @@ -24,6 +25,7 @@ module.exports.init = async(client) => { // For post methods .use(express.json()) .use(express.urlencoded({ extended: true })) + .use(cors()) // Set the engine to html (for ejs template) .engine("html", require("ejs").renderFile) .set("view engine", "ejs") diff --git a/dashboard/routes/docs.js b/dashboard/routes/docs.js index 9afa2404..91b7d4f8 100644 --- a/dashboard/routes/docs.js +++ b/dashboard/routes/docs.js @@ -2,8 +2,6 @@ const express = require("express"), router = express.Router(); router.get("/", function (req, res) { - res.set("Access-Control-Allow-Origin", "*"); - res.render("docs", { user: req.userInfos, translate: req.translate, diff --git a/package-lock.json b/package-lock.json index 6705f33a..e4a90677 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "canvacord": "^5.1.0", "canvas": "^2.10.2", "chalk": "^4.1.2", + "cors": "^2.8.5", "cron": "^2.1.0", "discord-giveaways": "^6.0.1", "discord-player": "^6.2.1", @@ -1247,6 +1248,18 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/cron": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/cron/-/cron-2.3.0.tgz", diff --git a/package.json b/package.json index 86c416b2..6b65cf85 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "canvacord": "^5.1.0", "canvas": "^2.10.2", "chalk": "^4.1.2", + "cors": "^2.8.5", "cron": "^2.1.0", "discord-giveaways": "^6.0.1", "discord-player": "^6.2.1",