diff --git a/package-lock.json b/package-lock.json index 42763eb..c4f4e2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@types/node": "^16.18.119", "bcrypt": "^5.1.1", "concurrently": "^9.0.1", + "cors": "^2.8.5", "deterministic-object-hash": "^2.0.2", "dotenv": "^16.4.5", "express": "^4.21.1", @@ -1835,6 +1836,19 @@ "version": "1.0.6", "license": "MIT" }, + "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==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/create-require": { "version": "1.1.1", "devOptional": true, diff --git a/package.json b/package.json index c0f6a7f..36467d4 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@types/node": "^16.18.119", "bcrypt": "^5.1.1", "concurrently": "^9.0.1", + "cors": "^2.8.5", "deterministic-object-hash": "^2.0.2", "dotenv": "^16.4.5", "express": "^4.21.1", diff --git a/src/index.ts b/src/index.ts index 5888a9a..ff4cd62 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import express, { type Response, type NextFunction, } from 'express'; +import cors from 'cors'; import swaggerJsDoc from 'swagger-jsdoc'; import swaggerUi from 'swagger-ui-express'; import swaggerOptions from '@/swagger'; @@ -29,6 +30,8 @@ process.on('uncaughtException', (error: Error) => { const app = express(); const logger = createLogger(); +app.use(cors()); + app.get('/', (req, res) => { res.json({ deployedCommitHash: `https://github.com/gitcoinco/checker-api/commit/${execSync('git rev-parse HEAD').toString().trim()}`,