forked from isomorphic-git/cors-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 801 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
'use strict'
const url = require('url')
const pkg = require('./package.json')
const {send} = require('micro')
const origin = process.env.ALLOW_ORIGIN
const insecure_origins = (process.env.INSECURE_HTTP_ORIGINS || '').split(',')
const middleware = require('./middleware.js')({ origin, insecure_origins })
async function service (req, res) {
middleware(req, res, () => {
let u = url.parse(req.url, true)
if (u.pathname === '/') {
res.setHeader('content-type', 'text/html')
let html = `<!DOCTYPE html>
<html>
<title>git.tabsets.net</title>
<h1>git.tabsets.net</h1>
<p>running...</p>
</html>
`
return send(res, 400, html)
}
// Don't waste my precious bandwidth
return send(res, 403, '')
})
}
module.exports = service