@rpcbase/server 0.282.0 → 0.284.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/express/index.js +3 -5
- package/package.json +1 -1
- package/express/block_invalid_hosts.js +0 -27
package/express/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const sessions = require("../src/sessions")
|
|
|
11
11
|
|
|
12
12
|
const dev_save_coverage = require("./dev_save_coverage")
|
|
13
13
|
const custom_cors = require("./custom_cors")
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
|
|
16
16
|
const log = debug("rb:server")
|
|
17
17
|
|
|
@@ -54,8 +54,6 @@ module.exports = () => {
|
|
|
54
54
|
app.use(Sentry.Handlers.tracingHandler())
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
block_invalid_hosts(app)
|
|
58
|
-
|
|
59
57
|
app.use(request_ip.mw())
|
|
60
58
|
|
|
61
59
|
app.use(body_parser.json({limit: `${BODY_MAX_SIZE_MB}mb`}))
|
|
@@ -76,8 +74,8 @@ module.exports = () => {
|
|
|
76
74
|
|
|
77
75
|
sessions(app)
|
|
78
76
|
|
|
79
|
-
app.get("/
|
|
80
|
-
app.post("/
|
|
77
|
+
app.get("/__ping", (req, res) => res.json({message: "pong"}))
|
|
78
|
+
app.post("/__ping", (req, res) => res.json({message: "pong"}))
|
|
81
79
|
|
|
82
80
|
auth(app)
|
|
83
81
|
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
const assert = require("assert")
|
|
3
|
-
|
|
4
|
-
const {APP_DOMAIN} = process.env
|
|
5
|
-
|
|
6
|
-
const is_production = process.env.NODE_ENV === "production"
|
|
7
|
-
|
|
8
|
-
const block_invalid_hosts = (app) => {
|
|
9
|
-
|
|
10
|
-
// only block invalid hosts in production
|
|
11
|
-
if (!is_production) return
|
|
12
|
-
|
|
13
|
-
app.use((req, res, next) => {
|
|
14
|
-
// dockerip.host is needed for platform/reverse-proxy
|
|
15
|
-
if (![APP_DOMAIN, "dockerip.host"].includes(req.hostname)) {
|
|
16
|
-
console.log("request from invalid hostname", {
|
|
17
|
-
hostname: req.hostname,
|
|
18
|
-
url: req.url
|
|
19
|
-
})
|
|
20
|
-
req.connection.destroy()
|
|
21
|
-
} else {
|
|
22
|
-
next()
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = block_invalid_hosts
|