From 9f9378d7939ad30429031b566c8eb5c607ee00ad Mon Sep 17 00:00:00 2001 From: Araozu Date: Thu, 29 Feb 2024 14:37:37 -0500 Subject: [PATCH] Allow cors from v2 --- srv/index.ts | 7 +++++-- srv/package.json | 2 ++ srv/pnpm-lock.yaml | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/srv/index.ts b/srv/index.ts index a034e22..4a02040 100644 --- a/srv/index.ts +++ b/srv/index.ts @@ -1,10 +1,13 @@ -import express from 'express'; +import express from "express"; import * as core from "express-serve-static-core"; -import Database from 'better-sqlite3'; +import Database from "better-sqlite3"; +import cors from "cors"; const app = express(); const port = 3485; +app.use(cors()); + const expressApp = (app: core.Express) => { app.use(express.json()); diff --git a/srv/package.json b/srv/package.json index 2009d77..4abbe09 100644 --- a/srv/package.json +++ b/srv/package.json @@ -11,11 +11,13 @@ "license": "ISC", "dependencies": { "better-sqlite3": "^9.4.3", + "cors": "^2.8.5", "express": "^4.18.3", "yaml": "^2.4.0" }, "devDependencies": { "@types/better-sqlite3": "^7.6.9", + "@types/cors": "^2.8.17", "@types/express": "^4.17.20", "@types/node": "^16.11.45", "typescript": "~4.7.4" diff --git a/srv/pnpm-lock.yaml b/srv/pnpm-lock.yaml index e3ae293..76cfa3e 100644 --- a/srv/pnpm-lock.yaml +++ b/srv/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: better-sqlite3: specifier: ^9.4.3 version: 9.4.3 + cors: + specifier: ^2.8.5 + version: 2.8.5 express: specifier: ^4.18.3 version: 4.18.3 @@ -19,6 +22,9 @@ devDependencies: '@types/better-sqlite3': specifier: ^7.6.9 version: 7.6.9 + '@types/cors': + specifier: ^2.8.17 + version: 2.8.17 '@types/express': specifier: ^4.17.20 version: 4.17.21 @@ -50,6 +56,12 @@ packages: '@types/node': 16.18.86 dev: true + /@types/cors@2.8.17: + resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} + dependencies: + '@types/node': 16.18.86 + dev: true + /@types/express-serve-static-core@4.17.43: resolution: {integrity: sha512-oaYtiBirUOPQGSWNGPWnzyAFJ0BP3cwvN4oWZQY+zUBwpVIGsKUkpBpSztp74drYcjavs7SKFZ4DX1V2QeN8rg==} dependencies: @@ -213,6 +225,14 @@ packages: engines: {node: '>= 0.6'} dev: false + /cors@2.8.5: + resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==} + engines: {node: '>= 0.10'} + dependencies: + object-assign: 4.1.1 + vary: 1.1.2 + dev: false + /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -533,6 +553,11 @@ packages: semver: 7.6.0 dev: false + /object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + dev: false + /object-inspect@1.13.1: resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} dev: false