Skip to content

Commit 3bf8d81

Browse files
committed
DEPLOY v0.2: Fix CORS error on deploy
1 parent dfb3ebf commit 3bf8d81

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const express = require('express');
77
const swaggerUi = require('swagger-ui-express');
88
const swaggerJsDoc = require('swagger-jsdoc');
9+
const cors = require('cors');
910

1011
// Constants
1112
const PORT = process.env.PORT ?? 3000;
@@ -14,6 +15,12 @@ const HOST = process.env.HOST ?? 'localhost';
1415
// Initialize Express app
1516
const app = express();
1617

18+
// Enable CORS for all requests
19+
app.use(cors());
20+
21+
// Add JSON body parser middleware
22+
app.use(express.json());
23+
1724
// Swagger setup
1825
const swaggerOptions = {
1926
definition: {

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"homepage": "https://github.com/CleanCodeIt/strix-backend#readme",
2424
"dependencies": {
25+
"cors": "^2.8.5",
2526
"express": "^5.1.0",
2627
"swagger-jsdoc": "^6.2.8",
2728
"swagger-ui-express": "^5.0.1"

0 commit comments

Comments
 (0)