feat: improve handling of deployment env vars
These are now defined in Netlify UI for dedicated environments (test, stage, production): AUTH_URL NEXTAUTH_URL PUBLIC_URL Code now falls back to incoming request host. Mainly used for deployment previews which do not have Akamai in front, meaning we do not need the above workaround as incoming request host matches the actual public facing host. When Akamai is in front, we lose the public facing host in Netlify's routing layer as they internally use `x-forwarded-for` and we can't claim it for our usage.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { metrics } from "@opentelemetry/api"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { env } from "@/env/server"
|
||||
import * as api from "@/lib/api"
|
||||
@@ -9,7 +10,9 @@ import type { FriendTransaction, Stay } from "./output"
|
||||
|
||||
const meter = metrics.getMeter("trpc.user")
|
||||
const getProfileCounter = meter.createCounter("trpc.user.profile")
|
||||
const getProfileSuccessCounter = meter.createCounter("trpc.user.profile-success")
|
||||
const getProfileSuccessCounter = meter.createCounter(
|
||||
"trpc.user.profile-success"
|
||||
)
|
||||
const getProfileFailCounter = meter.createCounter("trpc.user.profile-fail")
|
||||
|
||||
async function updateStaysBookingUrl(
|
||||
@@ -41,7 +44,7 @@ async function updateStaysBookingUrl(
|
||||
// Temporary Url, domain and lang support for current web
|
||||
const bookingUrl = new URL(
|
||||
"/hotelreservation/my-booking",
|
||||
env.PUBLIC_URL ?? ""
|
||||
env.PUBLIC_URL || "https://www.scandichotels.com" // fallback to production for ephemeral envs (like deploy previews)
|
||||
)
|
||||
switch (lang) {
|
||||
case Lang.sv:
|
||||
@@ -83,10 +86,7 @@ async function updateStaysBookingUrl(
|
||||
}
|
||||
|
||||
getProfileSuccessCounter.add(1)
|
||||
console.info(
|
||||
"api.user.profile updatebookingurl success",
|
||||
JSON.stringify({})
|
||||
)
|
||||
console.info("api.user.profile updatebookingurl success", JSON.stringify({}))
|
||||
|
||||
return data.map((d) => {
|
||||
const originalString =
|
||||
@@ -98,10 +98,7 @@ async function updateStaysBookingUrl(
|
||||
bookingUrl.searchParams.set("RefId", encryptedBookingValue)
|
||||
} else {
|
||||
bookingUrl.searchParams.set("lastName", apiJson.data.attributes.lastName)
|
||||
bookingUrl.searchParams.set(
|
||||
"bookingId",
|
||||
d.attributes.confirmationNumber
|
||||
)
|
||||
bookingUrl.searchParams.set("bookingId", d.attributes.confirmationNumber)
|
||||
}
|
||||
return {
|
||||
...d,
|
||||
@@ -113,4 +110,4 @@ async function updateStaysBookingUrl(
|
||||
})
|
||||
}
|
||||
|
||||
export { updateStaysBookingUrl }
|
||||
export { updateStaysBookingUrl }
|
||||
|
||||
Reference in New Issue
Block a user