@nitra/fastify 1.5.0 → 1.5.1
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/package.json +1 -1
- package/src/index.js +4 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fastify from 'fastify'
|
|
2
2
|
import fastifySensible from '@fastify/sensible'
|
|
3
3
|
import getLogger from '@nitra/bunyan/trace'
|
|
4
|
-
import { exit } from 'node:process'
|
|
4
|
+
import { exit, env } from 'node:process'
|
|
5
5
|
|
|
6
|
-
const port = Number(
|
|
6
|
+
const port = Number(env.PORT) || 8080
|
|
7
7
|
|
|
8
8
|
export const app = fastify({
|
|
9
9
|
// logger: isDev,
|
|
10
|
-
http2: !!
|
|
10
|
+
http2: !!env.K_SERVICE // Запускаємо з http2 якщо в Cloud Run
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
app.register(fastifySensible) // для reply.badRequest(`Not found url: ${req.url} ...`)
|
|
@@ -46,7 +46,7 @@ export function listen() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function setHeaders(req, reply) {
|
|
49
|
-
let host =
|
|
49
|
+
let host = env.ORIGIN || req.headers.origin || req.headers.referer
|
|
50
50
|
if (!host) {
|
|
51
51
|
host = 'localhost'
|
|
52
52
|
}
|