Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check now #168

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ dotenv.config();
const app = express();
const port = process.env.PORT || 3000;



// CORS configuration
app.use(
cors({
origin: ["http://localhost:5173", "https://play-cafe.vercel.app"],
})
);

// CORS configuration
const corsOptions = {
origin: ["http://localhost:5173", "https://play-cafe.vercel.app"],
};

Comment on lines +21 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consolidate CORS configurations to avoid duplication.

The newly added corsOptions object duplicates the origin array from the existing CORS configuration. To improve maintainability and reduce the risk of inconsistencies, consider consolidating these configurations.

Here's a suggested refactor:

- // CORS configuration
- app.use(
-   cors({
-     origin: ["http://localhost:5173", "https://play-cafe.vercel.app"],
-   })
- );

 // CORS configuration
 const corsOptions = {
   origin: ["http://localhost:5173", "https://play-cafe.vercel.app"],
 };

+ // Apply CORS middleware
+ app.use(cors(corsOptions));

This change eliminates duplication and ensures that any updates to allowed origins only need to be made in one place.

Committable suggestion was skipped due to low confidence.

app.use(express.json());

// MongoDB connection
Expand Down
Loading