forked from BETAIL-BOYS/TradeFlow-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cors-security.js
More file actions
33 lines (26 loc) · 975 Bytes
/
Copy pathtest-cors-security.js
File metadata and controls
33 lines (26 loc) · 975 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
29
30
31
32
33
// Simple test to verify CORS security fix
const fetch = require('node-fetch');
async function testCorsSecurity() {
console.log('Testing CORS security fix...');
try {
// Test with allowed origin
const allowedResponse = await fetch('http://localhost:3000/api', {
headers: {
'Origin': 'http://localhost:3000'
}
});
console.log('Allowed origin test - Status:', allowedResponse.status);
console.log('CORS headers:', allowedResponse.headers.raw());
// Test with disallowed origin
const disallowedResponse = await fetch('http://localhost:3000/api', {
headers: {
'Origin': 'https://malicious-site.com'
}
});
console.log('Disallowed origin test - Status:', disallowedResponse.status);
console.log('CORS headers:', disallowedResponse.headers.raw());
} catch (error) {
console.log('Test completed (server may not be running):', error.message);
}
}
testCorsSecurity();