-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcors.js
More file actions
28 lines (22 loc) · 669 Bytes
/
cors.js
File metadata and controls
28 lines (22 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const cors = require('cors');
const express = require('express');
const app = express();
// Configure CORS
app.use(cors({
origin: 'https://21xo.com', // Allow requests from this origin
credentials: true, // Allow cookies
}));
// Main domain route
app.get('/', (req, res) => {
res.send('Hello from main domain!');
});
// Subdomain route
const subdomain = express.Router();
subdomain.get('/', (req, res) => {
res.send('Hello from subdomain!');
});
app.use(express.vhost('app.21xo.com', subdomain));
// Start the server
app.listen(3000, () => {
console.log('Server is running on port 3000');
});