-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
37 lines (32 loc) · 923 Bytes
/
index.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
25
26
27
28
29
30
31
32
33
34
35
36
37
const proxy = require('express-http-proxy')
const express = require('express')
const dotenv = require('dotenv')
const path = require('path')
const cors = require('cors')
const app = express()
const { NODE_PORT = 5000 } = process.env
dotenv.config({ path: path.resolve(__dirname, '.env.local') })
app.use('/', express.static('dist'))
app.use(cors())
app.use('/client/v4', proxy('api.cloudflare.com', {
https: true,
proxyReqPathResolver: req => `/client/v4/${req.url}`,
proxyReqOptDecorator: opt => {
opt.headers['authorization'] = [
'Bearer',
process.env.VITE_API_AUTH_TOKEN
].join(' ')
return opt
}
}))
app.get('/oauth2/userinfo', (req, res) => {
res.json({
sub: 'Administrator'
})
})
app.get('/roles/:username', (req, res) => {
res.json({})
})
app.listen(NODE_PORT, () => {
console.log(`starting server on port ${NODE_PORT}`)
})