Skip to content

Commit

Permalink
add cors
Browse files Browse the repository at this point in the history
  • Loading branch information
AitorAlgorta committed Feb 13, 2024
1 parent 1df0d50 commit 72fafb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/components/schema-registry-manager/src/app.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
});
Expand Down
2 changes: 2 additions & 0 deletions backend/components/schema-registry-manager/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 72fafb0

Please sign in to comment.