From f3635df33348d2cd359a786adb7baf099fb052ce Mon Sep 17 00:00:00 2001 From: amy Date: Sat, 26 Oct 2024 22:04:55 +0330 Subject: [PATCH] cors --- main.js | 4 +++- package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index f751a94..405043c 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,6 @@ const express = require('express') const sqlite3 = require('sqlite3') +const cors = require('cors') const app = express() const db = new sqlite3.Database(':memory:'); @@ -12,7 +13,7 @@ db.serialize(() => { time TEXT )`); }); - +app.use(cors()); app.get('/', async (req, res) => { const url = req.query.url; @@ -73,6 +74,7 @@ app.get('/', async (req, res) => { res.status(500).send("damn"); return; } + res. res.contentType("application/json"); res.header("cache", "wasnt"); res.send(resp) diff --git a/package.json b/package.json index 23d971f..21a6f15 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "", "license": "ISC", "dependencies": { + "cors": "^2.8.5", "express": "^4.21.1", "sqlite3": "^5.1.7" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34461bc..cf9a810 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + cors: + specifier: ^2.8.5 + version: 2.8.5 express: specifier: ^4.21.1 version: 4.21.1 @@ -136,6 +139,10 @@ packages: resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} engines: {node: '>= 0.6'} + cors@2.8.5: + resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==} + engines: {node: '>= 0.10'} + debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -486,6 +493,10 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} deprecated: This package is no longer supported. + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + object-inspect@1.13.2: resolution: {integrity: sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==} engines: {node: '>= 0.4'} @@ -868,6 +879,11 @@ snapshots: cookie@0.7.1: {} + cors@2.8.5: + dependencies: + object-assign: 4.1.1 + vary: 1.1.2 + debug@2.6.9: dependencies: ms: 2.0.0 @@ -1275,6 +1291,8 @@ snapshots: set-blocking: 2.0.0 optional: true + object-assign@4.1.1: {} + object-inspect@1.13.2: {} on-finished@2.4.1: