optimize the way we consume env variables
This commit is contained in:
+7
-8
@@ -1,13 +1,12 @@
|
||||
import { type RequestHandler } from "express"
|
||||
import {
|
||||
FLY_REGION,
|
||||
IS_PRIMARY_REGION,
|
||||
PRIMARY_REGION,
|
||||
} from "~/lib/config.server"
|
||||
import { IS_PROD } from "~/lib/config.shared"
|
||||
import { IS_PROD } from "~/lib/constants"
|
||||
import { getServerEnv, isPrimaryRegion } from "~/lib/env"
|
||||
|
||||
const PRIMARY_REGION = getServerEnv("PRIMARY_REGION")
|
||||
const FLY_REGION = getServerEnv("FLY_REGION")
|
||||
|
||||
export const setFlyRegionHeader: RequestHandler = (req, res, next) => {
|
||||
res.setHeader("x-fly-region", FLY_REGION || "unknown")
|
||||
res.setHeader("x-fly-region", PRIMARY_REGION || "unknown")
|
||||
next()
|
||||
}
|
||||
|
||||
@@ -17,7 +16,7 @@ export const getReplayResponse: RequestHandler = (req, res, next) => {
|
||||
if (
|
||||
!IS_PROD ||
|
||||
["GET", "OPTIONS", "HEAD"].includes(method) ||
|
||||
IS_PRIMARY_REGION
|
||||
isPrimaryRegion()
|
||||
) {
|
||||
return next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user