We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 374863d commit 6822fd0Copy full SHA for 6822fd0
server/app.js
@@ -4,11 +4,24 @@ require('dotenv').config();
4
5
const app = express();
6
7
-app.use(cors());
8
-app.use(express.json());
+const allowedOrigins = [
+ 'http://localhost:5173',
9
+ 'https://store-management-frontend-kq05.onrender.com/'
10
+];
11
+
12
+app.use(cors({
13
+ origin: (origin, callback) => {
14
+ if (!origin || allowedOrigins.includes(origin)) {
15
+ callback(null, true);
16
+ } else {
17
+ callback(new Error('Not allowed by CORS'));
18
+ }
19
+ },
20
+ credentials: true
21
+})); app.use(express.json());
22
23
app.get('/', (req, res) => {
- res.send('API is running...');
24
+ res.send('API is running...');
25
});
26
27
const authRoutes = require('./routes/authRoutes');
0 commit comments