diff --git a/backend/components/schema-registry-manager/src/app.ts b/backend/components/schema-registry-manager/src/app.ts index 00857d77a..d26e25188 100644 --- a/backend/components/schema-registry-manager/src/app.ts +++ b/backend/components/schema-registry-manager/src/app.ts @@ -1,5 +1,7 @@ import dotenv from 'dotenv'; import express, {Express, Request, Response} from 'express'; +import cors from 'cors'; + import {SchemaProvider} from './types'; import { checkCompatibilityOfNewSchema, @@ -22,6 +24,14 @@ const currentProvider: SchemaProvider = SchemaProvider.karapace; // Middleware app.use(bodyParser.json()); +// CORS options +const corsOptions = { + origin: 'http://localhost:8080', +}; + +// Use cors middleware with the specified options +app.use(cors(corsOptions)); + app.get('/schemas.provider', (req: Request, res: Response) => { res.status(200).send(currentProvider); }); diff --git a/backend/components/schema-registry-manager/src/package.json b/backend/components/schema-registry-manager/src/package.json index 1cdd291b3..970c2ea5f 100644 --- a/backend/components/schema-registry-manager/src/package.json +++ b/backend/components/schema-registry-manager/src/package.json @@ -2,11 +2,13 @@ "dependencies": { "@types/express": "^4.17.21", "@types/node": "^20.10.3", + "cors": "^2.8.5", "dotenv": "^16.4.2", "express": "^4.18.2", "node-fetch": "^2.6.1" }, "devDependencies": { + "@types/cors": "^2.8.17", "@types/express": "^4.17.21", "@types/node": "^20.10.3", "ts-node": "^10.9.2",