-
Notifications
You must be signed in to change notification settings - Fork 0
/
cors-anywhere-selfhost.js
24 lines (24 loc) · 854 Bytes
/
cors-anywhere-selfhost.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let fs = require('fs');
// Listen on a specific host via the HOST environment variable
let host = process.env.HOST || '0.0.0.0';
// Listen on a specific port via the PORT environment variable
let port = process.env.PORT || 7788;
let cors_proxy = require('cors-anywhere');
cors_proxy
//The file path is default created by acme.
//Modify according to your specific situation.
.createServer({
httpsOptions: {
key: fs.readFileSync(
'/root/.acme.sh/YOUR.DOMAIN.com/YOUR.DOMAIN.com.key'
),
cert: fs.readFileSync('/root/.acme.sh/YOUR.DOMAIN.com/fullchain.cer'),
},
// Allow all origins
originWhitelist: [],
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2'],
})
.listen(port, host, function () {
console.log('Running CORS Anywhere on ' + host + ':' + port);
});